I’m trying to use strlen or something like that to count multiple set of characters
in a string.
Here’s the database string
xa1xb2xcxd3xe4xcxa5xb6xcxd7xe8xcxa9xb10xcxd11xe12xcxa13xb14xc
I get the string from the database and i want to count the number of
“xa” “xb” “xd” and “xe” that the string contains.
I Guess i could count first xa then xb then xd then xe with strlen and then adding the numbers but isn’t there an easier way?
Please help!
Are you open to
preg_match_allsolution?From the docs:
Although this returns the aggregated number of
xa,xb,xd and xe, not the individual onesIf you need to get individual ones, you need one more step with
array_count_values: