Salathe has made use of the ternary operator, it works like this:
( expression) ? ( expression2 ) : (expression3)
If expression is true, then PHP will evaluate to ( expression2 )
If expression1 is false, then it evaluates to ( expression3 )
To help you understand it further it can be rewritten like so:
PHP Code:
if(($pos = strpos($text0, '(')) !== FALSE ){
$text2 = substr($text0, 0, $pos);
}else{
$text2 = FALSE;
}
So, first PHP creates '$pos' and assigns the result of 'strpos' to it, then it functions like a regular IF, so if $pos is not equal to FALSE, or $pos not of the same type (which is what the !== comparison operator means, this is used because it will return an int on success and a bool false if it failed) then assign result of substr to $text2, else assign it FALSE.
As you can see using the ternary is smaller but at the same time can be tricky to read, especially if you nest them, which you shouldnt do, not unless you want to give yourself a headache, look at this snippet posted by salathe in another post:
PHP Code:
echo chr(16 + ((strlen('talkphp') + 1337) >> ((true === false)
? (('a' === chr(0x61)) ? 'talkphp' : 'php')
: ((767 & (405 - (pow(12, 2 * ('0'
? false : true))))))))),
chr('happy' ? 0x29 : 0x28);
edit : damn delayedinsanity beat me to it, i must learn to type faster!