[thelist] stupid PHP question
Árni Gunnar Ragnarsson
arnigunnar at gmail.com
Thu Jul 7 09:25:38 CDT 2005
Not a PHP specialist, but think I know what this is doing.
It is basically an IF --- THEN clause.
if (is_array($row)) {
$row_count = count($row);
} else {
$row_count = 0;
}
On 7/7/05, Nan Harbison <nan at heritageconcord.org> wrote:
> 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 !
>
--
------------------------------------------------------
Arni Gunnar Ragnarsson
EMAIL: arnigunnar at gmail.com
MSN: arnigunnar at hotmail.com
WEB: http://www.arnigunnar.net/
More information about the thelist
mailing list