2017-02-28 93 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