Skip to content

Instantly share code, notes, and snippets.

@gemmadlou
Last active October 14, 2016 08:35
Show Gist options
  • Select an option

  • Save gemmadlou/acbd64a0194a712df812ebf89e7011ce to your computer and use it in GitHub Desktop.

Select an option

Save gemmadlou/acbd64a0194a712df812ebf89e7011ce to your computer and use it in GitHub Desktop.
Typography Utility
<?php
class Typography {
public static function removeHangingWord($title) {
preg_match('/( )[&a-z]{1,2}([ ]){1}([&a-zA-Z]){3,}/', $title, $matches);
if (isset($matches[0])) {
$title_partial = str_replace(' ', '&nbsp;', ltrim($matches[0], ' '));
$title = str_replace($matches[0], " $title_partial", $title);
}
return $title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment