How can I count the number of times a comma appears in a string such as this?
A,B,C,D
It should return "3"
substr_count($my_string, ",")
If you wish to get all the elements between commas as an array, you can always
$splitted = explode(",", $my_string)
You could use e.g. substr_count(), or explode().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With