Page 1 of 1

Basic Syntax Help

Posted: Wed Nov 26, 2008 9:21 am
by cjconnor24
Hi all,

I have been following a tutorial on how to have an image gallery dynamically generate columns.

I have came across this line of code and i don't know what it does:

Code: Select all

$numImages = substr($row['thumb'],3) > 1 ? substr($row['thumb'],3) . ' images' : substr($row['thumb'],3) . ' image';
mainly what the ? and : do here? (i put the substr() on to trim the path!)

Any help would be appreciated!!!

Thanks,
C

Re: Basic Syntax Help

Posted: Wed Nov 26, 2008 10:30 am
by sparrrow
That is shorthand for if ? then : else

Re: Basic Syntax Help

Posted: Wed Nov 26, 2008 10:46 am
by cjconnor24
oh dear :oops:

sorry about that - didn't even know there was such a thing - just getting in to php.

much appreciated!!

c

Re: Basic Syntax Help

Posted: Wed Nov 26, 2008 11:57 am
by mmj