3

Is there a php array method that can tell me if an array has arrays as its values without doing a foreach loop?

1
  • Why do you want to avoid a foreach loop? Most likely an answer that involves a built-in function will do more work than you just creating a foreach loop to do this then toss it in a function. Commented Nov 11, 2012 at 12:49

2 Answers 2

3

print_r(array_filter($array, "is_array"));

3

You can use array_filter

$array = array(1,array(),2);
                     ^--------------- array in array

if(array_filter($array,"is_array"))
{
    // I found some arrays
}
1
  • Thanks. Id choose you since you used it in an if statement, but its pretty much the same as the other one. Commented Nov 11, 2012 at 13:00

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.