Forum Moderators: coopster
I need to compare a number ($id) if it's in the string. At first I thought, that strpos() will do the trick, but then it struck me, that 6 will be found (because of 56, ).
So what can I do?
Please help!
Michal Cibor
PS. I thought of exploding the string, but what then?
I thought of exploding the string, but what then
Once you explode the string, this creates any array of values. You can then use the in_array function.
$values = explode(",", $str);
$id = 'number';
Then use:
if (in_array($id, $values))
{
//true
}
else
{
//false
}
rojer_31, offers another alternative.
dc