[thelist] stupid PHP question

Nan Harbison nan at heritageconcord.org
Thu Jul 7 08:43:16 CDT 2005

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.

More information about the thelist mailing list