السلام عليكم ورحة الله وبركاته
عندي استفسار وارجو أن أجد الاجابة جزاكم الله خير
هل يوجد كود يجرد النصوص من html بحيث اريد النص فقط بدون أي كود html
مع تحياتي للجميع
السلام عليكم ورحة الله وبركاته
عندي استفسار وارجو أن أجد الاجابة جزاكم الله خير
هل يوجد كود يجرد النصوص من html بحيث اريد النص فقط بدون أي كود html
مع تحياتي للجميع
__________________
المركز العربي للبرمجة والتصميم
ما حك جلدك مثل ظفرك
وضعته للفائدةكود PHP:
function wordsonly ($text) {
//for the searching - strips out unneccessary bits
$text=strtolower($text);
$text=ereg_replace("<pre>[^<]*</pre>"," ",$text);
$text=ereg_replace("<[^>]*>"," ",$text); // remove HTML <> tags
$text=ereg_replace("&[^;];"," ",$text); // remove HTML special chars
// $text=ereg_replace("[^ 0-9a-z]"," ",$text); // keep only letters and numbers
$counter=0;
$words=explode(" ",$text);
while (list($key,$val)=each($words)) {
if (strlen($val)>2 and $val!="the" and $val!="this" and $val!="and" and $val!="but" and $val!="was" and $val!="that" and $val!="with" and $val!="its" and $val!="you" and $val!="they" and $val!="what" and $val!="why" and $val!="for" and $val!="are" and $val!="our" and $val!="then" and $val!="there" and $val!="which") {
$counter++;
$wordarray[]=$val;
}
}
if ($counter>0) {
return implode($wordarray," ");
}
}
والسلام عليكم
__________________
المركز العربي للبرمجة والتصميم
strip_tags
وتستخدم بطريقتين
http://www.php.net/manual/en/function.strip-tags.phpكود PHP:
strip_tags($str);
تلغي جميع علامات html
strip_tags($str, '<b></b>');
تسمح بعلامة <b> و </b>