In PHP, I am try to use "loop" to remove all excessive spaces. (NOT use string trimming functions and string replacement functions)
For example,
" I Love PHP"
> "I Love PHP"
.
There should be only one space between words.
Any idea? Thank you
$newstr = " "
for ($i = 0; $i < strlen($s), $i++ )
{
$newstr = $newstr.substr($s, $i, 1);
if (substr($s, $i, 1) == " ")
while(substr($s, $i + 1, 1) == " ")
$i++;
}
print (" test test test ")
?>