Domanda

come possiamo contare lo spazio tra il testo in php?

example: hi how are you?

spaces: 3

c'è un modo per contare gli spazi?

Lingua: solo PHP

È stato utile?

Soluzione

Usa questo:

substr_count($text, ' ');

Altri suggerimenti

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

Stai cercando preg_match_all .

$numSpaces = preg_match_all('/[ ]/', $testStr, $matches);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top