Reply to Re: switch easy

Your name:

Reply:


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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация