how to count space in a text statement in php

james picture james · Jun 23, 2009 · Viewed 19.8k times · Source

how can we count space between text in php ?

example: hi how are you?

spaces: 3

is there any way to count spaces ?

Language : Only PHP

Answer

gahooa picture gahooa · Jun 23, 2009

Use this:

substr_count($text, ' ');