{"id":798,"date":"2012-10-08T16:11:37","date_gmt":"2012-10-08T08:11:37","guid":{"rendered":"http:\/\/www.youthtribe.com\/?p=798"},"modified":"2012-10-08T16:11:37","modified_gmt":"2012-10-08T08:11:37","slug":"php%e4%b8%ad%e8%8b%b1%e6%96%87%e5%ad%97%e7%ac%a6%e6%88%aa%e5%8f%96%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"http:\/\/www.youthtribe.com\/archives\/798","title":{"rendered":"php\u4e2d\u82f1\u6587\u5b57\u7b26\u622a\u53d6\u51fd\u6570"},"content":{"rendered":"

\/\/\u622a\u53d6\u51fd\u6570
\n\u00a0function get_len($str){
\n\u00a0 $len = 0;
\n\u00a0 for($i=0;$i<strlen($str);$i++){
\n\u00a0\u00a0 if(ord($str[$i]) >= 65 && ord($str[$i]) <= 90){
\n\u00a0\u00a0\u00a0 $len += 1;
\n\u00a0\u00a0 }elseif(ord($str[$i]) < 127){
\n\u00a0\u00a0\u00a0 $len += 1;
\n\u00a0\u00a0 }else{
\n\u00a0\u00a0\u00a0 $i += 2;
\n\u00a0\u00a0\u00a0 $len += 2;
\n\u00a0\u00a0 }
\n\u00a0 }
\n\u00a0 return $len;
\n\u00a0}
\n\u00a0
\n\u00a0function sub_len($str,$len){
\n\u00a0 \/\/UTF8
\n\u00a0 $point = 0;
\n\u00a0 $return = “”;
\n\u00a0 $length = 0;
\n\u00a0 while($length <= $len){
\n\u00a0
\n\u00a0\u00a0 if(ord($str[$point]) >= 65 && ord($str[$point]) <= 90){
\n\u00a0\u00a0\u00a0 $return .= $str[$point++];
\n\u00a0\u00a0\u00a0 $length += 1;
\n\u00a0\u00a0 }elseif(ord($str[$point]) <128){
\n\u00a0\u00a0\u00a0 $return .= $str[$point++];
\n\u00a0\u00a0\u00a0 $length += 1;
\n\u00a0\u00a0 }else{
\n\u00a0\u00a0\u00a0 $return = $return . $str[$point++] . $str[$point++] . $str[$point++];
\n\u00a0\u00a0\u00a0 $length += 2;
\n\u00a0\u00a0 }
\n\u00a0 }
\n\u00a0 return $return;
\n\u00a0}
\n\u00a0\u00a0\u00a0 function str_cut($str,$len){
\n\u00a0\u00a0\u00a0\u00a0 if(get_len($str) > $len){
\n\u00a0\u00a0\u00a0\u00a0\u00a0 $title = sub_len($str,$len).”…”;
\n\u00a0\u00a0\u00a0\u00a0 }else{
\n\u00a0\u00a0\u00a0\u00a0\u00a0 $title = $str;
\n\u00a0\u00a0\u00a0\u00a0 }
\n\u00a0\u00a0\u00a0\u00a0 return $title;
\n\u00a0\u00a0\u00a0 }
\n\/\/<\/p><\/blockquote>\n

 <\/p>\n

\u8fd9\u4e2a\u51fd\u6570\u8fd8\u662f\u4e0d\u9519\u7684\uff0c\u6211\u7528\u4e86\uff0c\u8fbe\u5230\u6548\u679c \u4e86\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\/\/\u622a\u53d6\u51fd\u6570 \u00a0function get_len($str){ \u00a0 $len = 0; \u00a0 for($i=0;$i<strlen($str);$i++){ \u00a0\u00a0 if(ord($str[$i]) >= 65 && ord($str[$i]) <= 90){ \u00a0\u00a0\u00a0 $len += 1; \u00a0\u00a0 }elseif(ord($str[$i]) < 127){ \u00a0\u00a0\u00a0 $len += 1; \u00a0\u00a0 }else{ \u00a0\u00a0\u00a0 $i += 2; \u00a0\u00a0\u00a0 $len += 2; \u00a0\u00a0 } \u00a0 } \u00a0 return $len; \u00a0} \u00a0 \u00a0function sub_len($st<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,9],"tags":[134],"_links":{"self":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/798"}],"collection":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/comments?post=798"}],"version-history":[{"count":2,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/798\/revisions"}],"predecessor-version":[{"id":800,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/798\/revisions\/800"}],"wp:attachment":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/media?parent=798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/categories?post=798"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/tags?post=798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}