Re: syntax question

From: Date: Thu, 06 Mar 2003 09:28:38 +0000
Subject: Re: syntax question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138436@lists.php.net to get a copy of this message
It's fairly simple. The code you posted could also be written: if(strpos($a,'-')){ $a = explode('-',$a,2); }else{ $a = array($a); } It's called the ternary conditional operator. Unfortunatley, it's buried in the PHP manual. http://us2.php.net/manual/en/language.expressions.php Jimmy wrote:
I'm looking through some existing code for a project I'm working on, but I keep running into this syntax that I really don't understand. Here's an example: $a=strpos($a,'-')?explode('-',$a,2):array($a); What do the ? and the : do here? I'm seeing this sort of thing all over and just have no idea what ? : do. Thanks.
-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

« previous php.general (#138436) next »