It seems like the preg_match is working until it finds the first match and then stops:
$bgStr="<><><><><><><>";
$regStr='/</';
preg_match_all($regStr,$bgStr,$matches);
echo count($matches);
gives me the result of: "1". What am I missing?
It seems like the preg_match is working until it finds the first match and then stops:
$bgStr="<><><><><><><>";
$regStr='/</';
preg_match_all($regStr,$bgStr,$matches);
echo count($matches);
gives me the result of: "1". What am I missing?
There are at least 3 logical ways to achieve your count on the less than symbol. The last one listed being the best / most efficient / recommended one...
preg_match_all() is overkill. It creates an array in an array containing elements which must be counted.
count_chars() is overkill. It creates an array of elements like
CodeNumber=>Count
for each character found in the string.All methods above will output:
7