I wanted to count asterisks from a string starting with foo 'fooarbazlujabazlewis*bazbazlewbaz' and i should be able to count asterisk from another string starting with luja in short I wanted the starting string to be changed programmatically
I tried below code, but it counts any asterisk even if foo is not at the beginning
preg_match_all('/(^foo\*)*(\*)/', '*foo*arbaz*luj*abaz*lewis*bazbazlewbaz');
the result is 6. but in this case, I wanted it to fail since foo is not at the beginning.
if ( strpos($str, 'foo') === 0 ) echo substr_count($str, '*');