function center_word_wrap($text, $totWidth = 75, $multi_center = false) { if (strlen($text) <= $totWidth && !preg_match('/[\\200-\\377]/', $text)) { return str_pad($text, (int) (($totWidth + strlen($text)) / 2), " ", STR_PAD_LEFT) . "\n"; } $out = ""; while (($line = UnicodeHelper::utf8_line_break($text, $totWidth)) !== false) { $linelen = UnicodeHelper::utf8_glyphlen($line); $out .= str_pad($line, (int) (($totWidth + $linelen) / 2), " ", STR_PAD_LEFT) . "\n"; } return $out; }