i have a string like this $id = "2 4 8 10 88";
how do i compare another value with $id if the number is in that string?
I tried using stristr() but it doesn't seem to be working correctly. any other easy method?
Not sure if it is the fastest way, but you can use the split() function to convert your string into an array, and then the in_array() function to see if your new value is already in there.
http://us3.php.net/manual/en/function.split.php
http://us3.php.net/manual/en/function.in-array.php
yeah, i didn't want to use split() too slow 🙁 anyone know of a better method?
what about ereg or preg_match?
if guess with ereg it shoul looks like this:
if(ereg(" [0-9] ",$id,$regs)) echo $regs[0];