|
Posted by Sιverin Richard on 06/24/07 20:07
Thank you for your answer
I have many different extention to deal with and i will use switch
rather than ternary operator.
but i will keep in mind the > $_th = in_array($myswitch, $strings)
which may be usefull.
thx.
Michael Fesser wrote:
> .oO(severin)
>
>
>>What is the proper syntax (if exists) for:
>>
>>switch( $myswitch ){
>> case "str1" | "str2" | "str3" | "str4":
>> $_th = "user/".$url."/_thumb/".$file;
>> break;
>>
>> default:
>> $_th = $gfx."/file.gif";
>>}
>
>
> switch ($myswitch) {
> case 'str1':
> case 'str2':
> case 'str3':
> case 'str4':
> $_th = "user/$url/_thumb/$file";
> break;
> default:
> $_th = "$gfx/file.gif";
> }
>
> If there are just these two possible results, then you could also do it
> with a simple in_array() check and a ternary operator (a shortcut for an
> if-then-else statement):
>
> $strings = array('str1', 'str2', 'str3', 'str4');
> $_th = in_array($myswitch, $strings)
> ? "user/$url/_thumb/$file"
> : "$gfx/file.gif";
>
> Micha
[Back to original message]
|