tp5common.php ]+/iU', '', $str);}/** * 截取字符串 * * @name cutStr * @param $length 截取的个数 * @return string */function cutStr($strings, $length, $attrstr = '...') { if (strlen($strings) = $length) { return $strings; } $start =
]+>/iU', '', $str); } /** * 截取字符串 * * @name cutStr * @param $length 截取的个数 * @return string */ function cutStr($strings, $length, $attrstr = '...') { if (strlen($strings) <= $length) { return $strings; } $start = 0; $str = substr($strings, $start, $length); $char = 0; for ($i = 0; $i < strlen($str); $i++) { if (ord($str[$i]) >= 128) $char++; } $str2 = substr($strings, $start, $length + 1); $str3 = substr($strings, $start, $length + 2); if ($char % 3 == 1) { return $str3 . $attrstr; } if ($char % 3 == 2) { return $str2 . $attrstr; } if ($char % 3 == 0) { return $str . $attrstr; } } /** * 跳转 * * @name goUrl * @param string $msg 提示信息,可为空 * @param string $toUrl 要跳转的页面,为空为当前页面 */ function goUrl($msg = "", $toUrl = "") { $str = ''; echo $str; exit; } //取得文章里面的图片 function GetImageSrc($body) { if( !isset($body) ) { return ''; } else { preg_match_all ("/<(img|IMG)(.*)(src|SRC)=[\"|'|]{0,}([h|\/].*(jpg|JPG|gif|GIF|png|PNG))[\"|'|\s]{0,}/isU",$body,$out); return $out[4]; } } //提取文里面的URL function GetArticleUrl($body) { if( !isset($body) ) { return ''; } else { preg_match_all("/<(a|A)(.*)(href|HREF)=[\"|'|](.*)[\"|'|\s]{0,}>(.*)<\/(a|A)>/isU",$body,$out); return $out; } }