Check if string contains commas? I have a sting how I can verify that it contains values separated by commas or not.
example : $search=6,7,8,9,10
The php strpos function returns the position of the string; if it is not false or -1, then your string contains a character.
strpos
$searchString = ','; if( strpos($search, $searchString) !== false ) { echo "Found"; }
You can try using the preg_math or strpos methods.
$re = '/,/m'; $str = 'Hi...1,2,3,4'; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); // Print the entire match result var_dump($matches);