how to count space in a text statement in php how to count space in a text statement in php php php

how to count space in a text statement in php


Use this:

substr_count($text, ' ');


You're looking for preg_match_all.

$numSpaces = preg_match_all('/[ ]/', $testStr, $matches);


$arr = count_chars($str,1);echo $arr[32];