0

I am parsing from a plist file using php to Array, below is the var_dump of the array

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)

I need to remove array (size=4) so I get only as below, need help please.

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
  • You have an array or arrays, you CAN'T remove the outer array without losing the entire set? Commented Oct 29, 2013 at 9:19
  • Hello please specify the output of array using print_r() function so that we can identify the structure of array Commented Oct 29, 2013 at 9:52

2 Answers 2

1

You could try using var_dump on the content of your initial array, using a foreach loop :

foreach ($initial_array as $second_array){
var_dump($second_array);
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can use reset() function to remove outer array.

Eg:

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.