A little dab'll do ya
Code Snippets
Append Non-Breaking Space Between Last Two Words
<?php
function word_wrapper($text,$minWords = 3) {
$return = $text;
$arr = explode(' ',$text);
if(count($arr) >= $minWords) {
$arr[count($arr) - 2].= ' '.$arr[count($arr) - 1];
array_pop($arr);
$return = implode(' ',$arr);
}
return $return;
}
?>
You can shorten this to:
= $minWords)
? ' ' . array_pop($output)
: ' ' . array_pop($output);
$output = implode(' ',$output) . $widow;
return $output;
}
?>
EXACTLY what I needed. Thanks!
How to add non-breaking spaces to all words with less than 5 letters, not just 2 last?