<?php
function space($sentence) {
$sentence= trim($sentence); //trim function-Breaks a sentence after spaces.
//str_contains-Checks if there is a blank in this sentence in this situation.
while (str_contains($sentence, ' ')) {
// str_replace-Replaces the first element with the second element in this sentence.
$sentence= str_replace(' ', ' ',$sentence);
}
return $sentence;
}
$sentence " hi i am gvanca";
echo space($sentence);