/ Published in: PHP

This function will add soft hyphens after every 3rd character in words of over 10 characters. It will not leave fewer than three characters following a soft hyphen.
Known bugs: Adds soft hyphens to URLs and within HTML tags.
Known bugs: Adds soft hyphens to URLs and within HTML tags.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function SoftHyphens($text) { $return = ''; if ($wordLength > 10) { for ($i = 0; $i < $wordLength; $i++) { $return .= $words[$j][$i]; if ((($i % 3) == 2) && ($i < ($wordLength - 3)) && ($i > 0)) { $return .= '­'; } } } else { $return .= $words[$j]; } } return $return; }
URL: http://www.addedbytes.com
Comments
