php - preg_match find only this special character "|" in string -


this question has answer here:

hi want find if string content "|" character.

example:-

$string = '$18,000 | new price';   if (preg_match('/[^|]/', $string)) {  } else {  } 

this should work.

$string = '$18,000 | new price';   if (strpos($string , '|') === false) {      // not found. } else {     // found. } 

http://php.net/strpos


Comments