2009-05-06 105 views
2

確定這裏是我想要做的。我有一個數組。我想要做的是從第一個索引值的另一個數組。就拿下面我想創建和數組從這個:使用另一個數組的索引值創建一個數組

Array ( 
    [identifier] => ID 
    [label] => HouseNum 
    [items] => Array ( 
         [0] => Array ( 
            [ID] => 1 
            [HouseNum] => 17 
            [AptNum] => 
            [Street] => birch glen dr 
            [City] => Clifton Park 
            [State] => NY [Zip5] => 
            [EID] => E083223 
            [RequestDate] => 02/05/09 
            [Status] => In-Qeue 
            [DateCompleted] => 
            [CompletedBy] => 
            [ContactName] => Suzy Q 
            [ContactNumber] => 555-867-5309 
            [ContactTime] => 9-9) 
         ) 
    ); 

這將最終看起來像這樣:

Array(
     [0] => [ID] 
     [1] => [HouseNum] 
     [2] => [AptNum] 
     [3] => [Street] 
     [4] => [City] 
     [5] => [State] 
     [6] => [Zip5] 
     [7] => [EID] 
     [8] => [RequestDate] 
     [9] => [Status] 
     [10] => [DateCompleted] 
     [11] => [CompletedBy] 
     [12] => [ContactName] 
     [13] => [ContactNumber] 
     [14] => [ContactTime] 
    ); 

就如何實現這一目標有什麼想法?我主要需要知道如何獲得索引值。

回答

0
foreach($items[0] as $idx => $val) 
    { 
    $indexes[] = $idx; 
    } 

或者:

$indexes = array_keys($items[0]); 
0
$result = array_keys($input['items'][0]); 
相關問題