Skip to content
Advertisement

How to count space in a text statement in PHP

How can we count space between text in PHP?

example: hi how are you?

spaces: 3

Is there a way to count spaces?

Language: Only PHP

Advertisement

Answer

Use this:

substr_count($text, ' ');
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement