> -----Original Message----- > From: Mako Shark [mailto:[EMAIL PROTECTED]] > Sent: 28 November 2002 18:20 > > A little more info on my count()ing. > I have $issue[0]["number"] to $issue[x]["number"] just > like any other multidimensional array (we'll call them > m-arrays for simplicity). > > If I try to count($issue), I'll get all instances of > my array (instances?) mltipled by the number of > elements
Uh -- have you actually tried this? Without doing so myself, I'm 99% sure that count($issue) will give you the answer you're looking for -- i.e. the number of different subscripts in the first dimension. From your description of how you expect count() to work, I suspect you're labouring under a misapprehension about how PHP arrays are built: in this case, $issue is an array of (x+1) elements, indexed from 0 to x, each element of which just happens to contain an array itself; it's not a single array of (x+1)*(no. of "string" subscripts) elements. This means you can do something like $current = $issue[0] and $current will be the array of string-subscripted elements contained in $issue[0]. > My problem is I need to loop through these. Well, you don't need to know how many there are to do this -- just use foreach: foreach ($issue as $n=>$elements): // in here, $elements['number']==$issue[$n]['number'], etc. endforeach; Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php