...

View Full Version : If is in a multidimentional array



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

$requestedDates[$i]['dayNum']

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?

Inigoesdr
01-27-2012, 03: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.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum