Well, counting is easy...  count($issue) will be correct.  If you want
to count things that match only specific elements, use things like:

  $c=0;
  foreach($issue as $what)
    if ( $year==2003 && $month>=5 )
      $c++;

As I said in the previous email, to sort by array elements, you'd need
to use array_multisort.  Something like...

  $sortkey=array();
  foreach($issue as $what)
    $sortkey[]=$what['number'];
  array_multisort($issue,$sortkey);

And for looping, foreach is still your best bet:

  foreach($issue as $key => $what) {
    if ($what['senttosubscribers']==0)
      $issue[$key]['description'].=" (EMPTY)";
    else
      $issue[$key]['description'].=str_replace(" (EMPTY)","",$what['description']);
  }

With regard to PHP being "screwey", I haven't found this -- I use
multidimensional arrays quite a bit and find that they behave exactly as
I would predict.  Maybe I'm just lucky.  ;-)

p

On Thu, Nov 28, 2002 at 09:55:25AM -0800, Mako Shark wrote:
> 
> Wow. This goes way beyond simply printing
> multidimensional arrays. Here's some sample data:
> 
> $issue[]["number"] = "number";
> $issue[]["headline"] = "headling";
> $issue[]["writers"] = "writers";
> $issue[]["list"] = "list";
> $issue[]["senttosubscribers"] = "0";
> $issue[]["month"] = "05";
> $issue[]["year"] = "2003";
> $issue[]["description"] = "description";
> 
> What I need to do now is count(), sort() by number,
> and loop through this array.
> 
> I read that PHP is screwy when counting and sorting
> multidimensional arrays, but they *have* to have come
> up with a method, right?

-- 
  Paul Chvostek                                             <[EMAIL PROTECTED]>
  Operations / Abuse / Whatever                          +1 416 598-0000
  it.canada - hosting and development                  http://www.it.ca/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to