You are here: Re: Simplifying a basic if statement conditional « PHP Programming Language « IT news, forums, messages
Re: Simplifying a basic if statement conditional

Posted by Ciaran on 05/19/07 18:02

On May 19, 6:44 pm, purcaholic <purcaho...@googlemail.com> wrote:
> On 19 Mai, 14:47, Ciaran <cronok...@hotmail.com> wrote:
>
> > Is there a more efficient way to write this:
> > if($var=1 || $var=4 || $var=27 || $var=28 || $var=30 || $var=37 ||
> > $var=38){echo "true";}
>
> > Cheers,
> > Ciarán
>
> Other way to simplify it is to compose a string using a delemiter
> character and to search inside composed string, like:
>
> if (strstr("|".$var."|", "|1|2|27|28|30|37|38|")) {
> echo "true";
>
> }
>
> purcaholic


All great ideas guys! Thanks for the replies on this. I especially
like purcaholic's one! Anyone know which of these methods would be the
fastest? Are any of them actually any faster than the basic one I
posted at the start?

Cheers,
Ciarán

 

Navigation:

[Reply to this 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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация