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
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
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];
$text = "Biography of the author of Riyād al-Sālihīn";
$spaces = substr_count($text,' ') ?: 0; // if override spaces from sentences
$data = substr($text,0,$length + $spaces); //`enter code here
© 2022 - 2024 — McMap. All rights reserved.