Jump to content

Probably a quick question


jay.barnes

Recommended Posts

I would just use strpos() or stristr() to check if there is a comma in that string, as they are faster.

 

$cityandstate = "New York, NY";
if (str_pos($cityandstate, ",") === true)
{
     echo "true";
}

 

$cityandstate = "New York, NY";
if(strpos($cityandstate, ",")) {
echo "true";
}

 

AAhhh...I understand now...I thought ($cityandstate, ",") was setting the comma as the delimiter - I read the manual page wrong.

 

I"m basically trying to find out if a string contains a comma, and, if it does, execute some commands

 

I'll look at strpos(), and see if that better suits my needs.

 

Thanks for your help, guys!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.