Saturday, August 11, 2012

Remove whitespace from both sides of a string with php

//Remove whitespace from both sides of a string in php

function removeSideSpace($str)
{

return trim($str);

}

$yourString="  This  is test for the string    ";

echo " <br> Before remove the space == ".strlen($yourString);

$yourString= removeSideSpace($yourstring);

echo " <br> After remove the space == ".strlen($yourString);


?>

No comments:

Post a Comment