' ); //$txt = remove( $txt, '本 港', '預 測' ); $txt = str_replace(" ", "", $txt); print nl2br(utf_wrap(trim($txt),16,"\n")); function utf_wrap($txt, $wid, $cr) { $txt = str_replace(chr(13), "", $txt); $txt = str_replace(chr(10).chr(10), chr(13), $txt); $txt = str_replace(chr(10), '', $txt); $txt = str_replace(chr(13), chr(10).chr(10), $txt); $txt = trim($txt); $s = ''; $j = 0; for($i=0; $i=161 && $o<=254) ? 2 : 1; if ($j+$clen > $wid) { $s .= $cr; $j = 0; } if ($clen==1) { $s .= substr($txt,$i,1); $j++; continue; } if ($i>strlen($txt)-2) { $s .= '?'; break; } $s .= substr($txt,$i,3); $j += 2; $i += 2; } return $s; } function remove($s, $t1, $t2, $unless='') { // remove segment $t1??$t2 from string $s $i = 0; do { $i = strpos( $s, $t1, $i); if ($i === false) return $s; if ( ($j = strpos( $s, $t2, $i)) === false ) return substr($s,0,$i); if ( empty($unless) or strpos( substr($s,$i,$j), $unless)===false ) { $s = substr($s, 0, $i) . substr($s, $j+strlen($t2)); } else { $i = $j + strlen($t2); } } while (1); } function between($s, $t1, $t2) { // return segment $t1??$t2 from string $s $i = strpos( $s, $t1); // if ($i === false) return $s; if ($i === false) return ''; $j = strpos( $s, $t2, $i); if ($j === false) return substr($s,strlen($t1)+$i); return substr(substr($s,0,$j),strlen($t1)+$i); } ?>