How do I remove multiple blank lines from a string.
I have looked at the examples on stackoverflow and have tried to change my code accordingly but I am not getting the right answer.
function removeMultipleBlankLines(&$array)
{
$value = $array;
$value = preg_replace("/(^[
]*|[
]+)[s]*[
]+/", "
", $value);
return $value;
}
$textarray=array("The red","big"," "," ","fox","is ready","","","to jump.");
echo print_r(removeMultipleBlankLines($textarray));
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…