|
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
[Back to original message]
|