public static function shyphenate($str) { $res = preg_match_all('/([a-z0-9]{19,})/i', $str, $matches); if ($res) { foreach ($matches[1] as $key => $match) { $str = str_replace($match, wordwrap($match, 10, '­', true), $str); } } return $str; }
/** * Add 'soft hyphens' ­ to a string, so that it won't break layout in HTML when * using strings without spaces or dashes. * * @param string $str * * @return string */ public function shy($str) { if (is_string($str)) { $str = Str::shyphenate($str); } return $str; }