September 13th, 2009, 11:55 PM
I need to match a string that is the word "cat", an integer, and a comma... Like this:
I've tried this:
But that's not it...
September 14th, 2009, 04:05 AM
You don't want the beginning an end ^ and $, and probably want to select the values as a group (with brackets).
preg_match_all("/(cat\d+,)/", $cats, $matches);
preg_match_all("/^(cat\d+,)*$/", $cats, $matches);
if you want to see if the entire string contains nothing but cats
Last edited by Mark Baker; September 14th, 2009 at 04:11 AM.
9 out of 10 PHP problems can be resolved by setting
php -l <filename> will identify 9 out of the remaining 10 problems
Remember, the command line
is your friend