从数组

时间:2016-12-21 18:04:11

标签: php arrays

给出这个数组:

  

数组([coordinates] =>数组([0] =>数组([0] => 0 | 0)[1] =>数组([0] => 37.364358914717755 | -5.989565849304199 [ 1] => 37.36858828480959 | -5.9893083572387695 [2] => 37.36892935265444 | -5.9857892990112305 [3] => 37.3615619422531 | -5.985960960388184 [4] => 37.363813172179285 | -5.989136695861816)[2] =>数组([0 ] => 37.38147957088128 | -5.985403060913086 [1] => 37.39307301476918 | -5.968408584594727 [2] => 37.382570794963435 | -5.953130722045898 [3] => 37.376841691380825 | -5.971841812133789 [4] => 37.37629603964236 | -5.985231399536133)[ 3] =>数组([0] => 37.375341139548176 | -5.952787399291992 [1] => 37.38093395288545 | -5.950899124145508 [2] => 37.3791606669827 | -5.940771102905273 [3] => 37.37124857287921 | -5.943517684936523)[4 ] =>数组([0] => 37.360265748932 | -5.9824419021606445 [1] => 37.36476821901685 | -5.9783220291137695 [2] => 37.360129306227435 | -5.9706830978393555 [3] => 37.3569228312597 | -5.9761762619018 555)))

我需要得到这个:

  

数组([0] =>数组([0] => 0 | 0)[1] =>数组([0] => 37.364358914717755 | -5.989565849304199 [1] => 37.36858828480959 | - 5.9893083572387695 [2] => 37.36892935265444 | -5.9857892990112305 [3] => 37.3615619422531 | -5.985960960388184 [4] => 37.363813172179285 | -5.989136695861816)[2] =>数组([0] => 37.38147957088128 | -5.985403060913086 [1] => 37.39307301476918 | -5.968408584594727 [2] => 37.382570794963435 | -5.953130722045898 [3] => 37.376841691380825 | -5.971841812133789 [4] => 37.37629603964236 | -5.985231399536133)[3] =>数组([] 0] => 37.375341139548176 | -5.952787399291992 [1] => 37.38093395288545 | -5.950899124145508 [2] => 37.3791606669827 | -5.940771102905273 [3] => 37.37124857287921 | -5.943517684936523)[4] =>数组([0 ] => 37.360265748932 | -5.9824419021606445 [1] => 37.36476821901685 | -5.9783220291137695 [2] => 37.360129306227435 | -5.9706830978393555 [3] => 37.3569228312597 | -5.9761762619018555))

我尝试在php中使用str_replace,但就数组来说它不起作用。

我用许多其他功能进行了很多测试,但我对此感到很遗憾。

任何想法?。

谢谢!

1 个答案:

答案 0 :(得分:0)

您的数组看起来像:

$yourArrayVariable = Array(
    [cordinates] => array (
         [0] => data0
         [1] => data1
         [2] => data2
    )
)

所以你只需访问内部数组,如:

$onlyInnerArray = $yourArrayVariable[cordinates];

之后,您可以更深入地访问特定数据,如

$onlyInnerArray = $yourArrayVariable[cordinates][0];