需要删除数组输出中的数组

时间:2013-10-29 09:17:44

标签: php arrays

我使用php解析plist文件到Array,下面是数组的var_dump

array (size=4)
0 => 
array (size=6)
  'EventId' => string 'Event1-2013-10-22' (length=17)
  'EventName' => string 'Event1' (length=6)
  'EventDate' => string '2013-10-21' (length=10)
  'EventDetails' => string ' ' (length=1)
  'Field1' => string 'Testing' (length=7)
  'Field2' => string '' (length=0)
1 => 
array (size=6)
  'EventId' => string 'Event2-2013-10-24' (length=17)
  'EventName' => string 'Event2' (length=6)
  'EventDate' => string '2013-10-24' (length=10)
  'EventDetails' => string ' EVe2' (length=5)
  'Field1' => string 'Testing22' (length=9)
  'Field2' => string '' (length=0)

我需要移除array (size=4),所以我只能获得如下所示,需要帮助。

0 => 
array (size=6)
  'EventId' => string 'Event1-2013-10-22' (length=17)
  'EventName' => string 'Event1' (length=6)
  'EventDate' => string '2013-10-21' (length=10)
  'EventDetails' => string ' ' (length=1)
  'Field1' => string 'Testing' (length=7)
  'Field2' => string '' (length=0)
1 => 
array (size=6)
  'EventId' => string 'Event2-2013-10-24' (length=17)
  'EventName' => string 'Event2' (length=6)
  'EventDate' => string '2013-10-24' (length=10)
  'EventDetails' => string ' EVe2' (length=5)
  'Field1' => string 'Testing22' (length=9)
  'Field2' => string '' (length=0)

2 个答案:

答案 0 :(得分:1)

您可以尝试在初始数组的内容上使用var_dump,使用foreach循环:

foreach ($initial_array as $second_array){
var_dump($second_array);
}

答案 1 :(得分:0)

您可以使用reset()函数删除外部数组。

例如:

<?php
$outer_array = array(0 => array(
                            'key1' => 'value1',
                            'key2' => 'value2'
 ));

$new_array = reset($outer_array);
print_r($new_array);
?>