How to count space in a text statement in PHP

count, php, spaces, text

Solution

Use this:

substr_count($text, ' ');

Problem

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

Original source