I have an array myArray
Array ([0] =>(
         Number => 02348
         Food => Array (
             [0] => orange
             [1] => apple
             [2] => plum )
         State => Array (
             [0] => california
             [1] => texas
             [2] => arizona )
        Status => good )
       [1] =>(
         Number => 34
         Food => Array (
             [0] => grape
             [1] => bannana
             [2] => tomato )
        Status => rotten )
        [2] =>(
         Number => 007
         Food => Array (
             [0] => oranges
             [1] => apples
             [2] => plums )
         State => Array (
             [0] => ohio
             [1] => utah
             [2] => vermont )
        Status => good )
I am looping though my array and then grabbing the fields i need.
for($index=0; $index < count($myArray); $index++){
   $food = array_values(array_filter($myArray[$index]["Food"]));
   $states = array_values(array_filter($myArray[$index]["State"]));
For the $states line i get an error of
Notice: Undefined index: State 
Warning: array_filter() expects parameter 1 to be array, null given
As you can see in my array State may not always be present, is there a way to get around this. Also there is a large amount of data is being pulled dynamically and it would be difficult to change the structure of the array. How can i loop though my array ignoring nulls but still keeping the place of State. For example
State => Array (
         [0] => ohio
         [1] => utah
         [2] => vermont )
would still be mapped to the [2], and not shifted to [1].
 
    