2017-02-28 71 views
1

我有內部許多陣列(關聯數組)多多維數組導致,我想更換內部數組爲索引的數組 原始數組導致這樣的:轉換多維相關陣列要被索引陣列

Data Saved: Array 
(
    [0] => Array 
     (
      [fullname] => john 
      [ServiceDescAR] => description 
      [user_id] => 13 
      [pos] => 29.958040,30.915489 
      [icon] => http://maps.google.com/mapfiles/ms/icons/green.png 
      [distance] => 0.00460411726624673 
     ) 

    [1] => Array 
     (
      [fullname] => angel 
      [ServiceDescAR] => description 
      [user_id] => 11 
      [pos] => 29.958042,30.915478 
      [icon] => http://maps.google.com/mapfiles/ms/icons/green.png 
      [distance] => 0.005705603509640217 
     ) 

) 

,我想,以取代被索引的所有鍵,它會像這樣 如何做到這一點

Data Saved: Array 
(
    [0] => Array 
     (
      [1] => john 
      [2] => description 
      [3] => 13 
      [4] => 29.958040,30.915489 
      [5] => http://maps.google.com/mapfiles/ms/icons/green.png 
      [6] => 0.00460411726624673 
     ) 

    [1] => Array 
     (
      [1] => angel 
      [2] => description 
      [3] => 11 
      [4] => 29.958042,30.915478 
      [5] => http://maps.google.com/mapfiles/ms/icons/green.png 
      [6] => 0.005705603509640217 
     ) 

) 

回答

3

您可以使用array_values提取所有值從陣列(無日e鍵):

$result = array_map('array_values', $inputArray); 

生成的內部數組索引將從零開始。

+0

爲什麼我看到這個錯誤 – user1080247

+0

一個PHP錯誤遇到

嚴重性:注意

消息:使用未定義的常量array_values的 - 假設 'array_values'

user1080247

+0

此修復錯誤 – user1080247