Problem: When description content requires the value of description, the first 50 characters of the information content are selected. Information content may have pictures.
The content of the output needs to be processed at this time
PHP Regular expression processing, the content of the editor output
Take pictures only:
Preg_match ('/<\s*img\s+[^>]*?src\s*=\s* (\ ' |\ ') (. *?) \\1[^>]*?\/?\s*>/i ', $news _detail[' dnews_content '], $match);
Simplest: Only text strip_tags ($news _detail[' dnews_content ');
Remove all spaces and HTML tags (including line breaks )
Regular expressions remove all spaces and HTML tags (including line breaks)
Preg_replace ("/(\s|\ \;| | \XC2\XA0)/"," ", Strip_tags ($STR));
Introduction: In the WAP development, access to the content of the article when the picture is set wide and high, so that in the phone will not be less than the narrowing, how to use PHP code to filter the width of the img? Matches only Chinese without English and punctuation
$htmldescription Preg_replace Strip_tags ($news _detail[' dnews_content ']));
PHP preg_replace filter img Width high
<?PHP$str= ' ; EchoContent_strip ($str); functionContent_strip ($content) { $content=Preg_replace('/]*src=[\ ' ")? ([^>\ ' "\s]*) [\‘"]? [^>]*>/ie ', ' wap_img (' $ ') ',$content); return $content; } functionWap_img ($url) { return' $url. ' "width=" 100% ">"; } ?>
Design Information module in SHONC Project PHP string manipulation and regular expression Strip_tags Preg_match