View Full Version : If is in a multidimentional array

01-27-2012, 04:08 PM
I have an array formed like


which contains the day number of whatever dates are in another array (day number e.g 1 through to 7 (mon to sun))

I need to search through and find out how many 6's and 7's are in, what would be the best way of doing it? I can only think of using foreach loops but surely theres a better way than that?

01-27-2012, 04:24 PM
foreach() (http://php.net/foreach) is the way to go if you are starting with a multidimensional array. If it was a single dimension you could use array_count_values() (http://php.net/array_count_values). You still could really, if you make an array of the values first.

01-27-2012, 04:28 PM
Okay, thanks, i didnt know if there was a better way or not.