true, '1' => true, '2' => true, '3' => true, '4' => true, '5' => true, '6' => true, '7' => true, '8' => true, '9' => true); for($position = 0; $position <= ($word_length - $GLOBALS["charmin"]); $position++) { $maxwins = min(($word_length - $position), $GLOBALS["charmax"]); for($win = $GLOBALS["charmin"]; $win <= $maxwins; $win++) { if(isset($GLOBALS["patterns"][mb_substr($text_word, $position, $win)])) { $pattern = $GLOBALS["patterns"][mb_substr($text_word, $position, $win)]; $digits = 1; $pattern_length = mb_strlen($pattern); for($i = 0; $i < $pattern_length; $i++) { $char = $pattern[$i]; if(isset($numb3rs[$char])) { $zero = ($i == 0) ? $position - 1 : $position + $i - $digits; if(!isset($hyphenated_word[$zero]) || $hyphenated_word[$zero] != $char) $hyphenated_word[$zero] = $char; $digits++; } } } } } $inserted = 0; for($i = $GLOBALS["leftmin"]; $i <= (mb_strlen($word) - $GLOBALS["rightmin"]); $i++) { if(isset($hyphenated_word[$i]) && $hyphenated_word[$i] % 2 != 0) { array_splice($single_character, $i + $inserted + 1, 0, $GLOBALS["hyphen"]); $inserted++; } } return implode('', array_slice($single_character, 1, -1)); } // Text hyphenation function hyphenation($text) { global $exclude_tags; $word = ""; $tag = ""; $tag_jump = 0; $output = array(); $word_boundaries = "<>\t\n\r\0\x0B !\"§$%&/()=?….,;:-–_„”«»‘’'/\\‹›()[]{}*+´`^|©℗®™℠¹²³"; $text = $text . " "; for($i = 0; $i < mb_strlen($text); $i++) { $char = mb_substr($text, $i, 1); if(mb_strpos($word_boundaries, $char) === false && $tag == "") { $word .= $char; } else { if($word != "") { $output[] = word_hyphenation($word); $word = ""; } if($tag != "" || $char == "<") $tag .= $char; if($tag != "" && $char == ">") { $tag_name = (mb_strpos($tag, " ")) ? mb_substr($tag, 1, mb_strpos($tag, " ") - 1) : mb_substr($tag, 1, mb_strpos($tag, ">") - 1); if($tag_jump == 0) { if(in_array(strtolower($tag_name), $exclude_tags)) $tag_jump = 1; else { $output[] = $tag; $tag = ""; } } else { $output[] = $tag; $tag = ""; } } if($tag == "" && $char != "<" && $char != ">") $output[] = $char; } } $text = join($output); return substr($text, 0, strlen($text) - 1); } ?>