0

I have this array:

 <?php
    $arr = array('submitted',
                 'region' => array('value 1','value2','value3'),
                 'sended',
                 'something' => array('value','value'));

  ?>

The question is how to check if an element is an array and print the corresponding key.

The output should be:

region  something
3
  • i dont understand what do you want exactly, please describe it better Commented Dec 9, 2012 at 16:09
  • i want to check if an element is an array in the main array and print the element name Commented Dec 9, 2012 at 16:12
  • 1
    question is clear enough Commented Dec 9, 2012 at 16:12

1 Answer 1

4
foreach ($arr as $k=>$a) {
    if (is_array($a)) echo $k;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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