[thelist] stupid PHP question

Chris Hayes chris at lwcdial.net
Thu Jul 7 09:25:27 CDT 2005


Looks like a short  for:

if  is_array($row)
    $row_count  = count($row)
else
    $row_count  = 0

I don't know PHP much but it looks similar in other languages.


----- Original Message ----- 
From: "Nan Harbison" <nan at heritageconcord.org>
To: <thelist at lists.evolt.org>
Sent: Thursday, July 07, 2005 2:43 PM
Subject: [thelist] stupid PHP question


> Hello All,
>
> I have this function $array is a two dimensional array being retrieved
from
> a table):
>
>    foreach ($array as $row)
>    {
>      $row_count = is_array($row) ? count($row) : 0;
>      if ($row_count > $max_cols)
>      {
>         $max_cols = $row_count;
>      }
>    }
>
> What I don't understand is the syntax of this line:
>
> $row_count = is_array($row) ? count($row) : 0;
>
> I have spent hours looking through my PHP books, but can't find it. Can
> someone please explain what the question mark is doing? And the
count($row)
> : 0?
>
> Sorry, I know this is a dumb question.
> TIA,
> Nan
>
>
> -- 
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !



More information about the thelist mailing list