הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 08-10-10, 15:14   # 18
Erez | TrustMedia.co.il
עסק רשום [?]
 
מיני פרופיל
תאריך הצטרפות: Jul 2008
הודעות: 1,854

Erez | TrustMedia.co.il לא מחובר  

אם היית מסתכל בתגובות לפונקציה strip_tags היית מוצא לא מעט פתרונות כאלו:
PHP קוד:
<?php
function strip_only($str$tags$stripContent false) {
    
$content '';
    if(!
is_array($tags)) {
        
$tags = (strpos($str'>') !== false explode('>'str_replace('<'''$tags)) : array($tags));
        if(
end($tags) == ''array_pop($tags);
    }
    foreach(
$tags as $tag) {
        if (
$stripContent)
             
$content '(.+</'.$tag.'[^>]*>|)';
         
$str preg_replace('#</?'.$tag.'[^>]*>'.$content.'#is'''$str);
    }
    return 
$str;
}

$str '<font color="red">red</font> text';
$tags 'font';
$a strip_only($str$tags); // red text
$b strip_only($str$tagstrue); // text
?>
PHP קוד:
function strip_selected_tags($str$tags ""$stripContent false)
{
    
preg_match_all("/<([^>]+)>/i"$tags$allTagsPREG_PATTERN_ORDER);
    foreach (
$allTags[1] as $tag) {
        
$replace "%(<$tag.*?>)(.*?)(<\/$tag.*?>)%is";
        
$replace2 "%(<$tag.*?>)%is";
        echo 
$replace;
        if (
$stripContent) {
            
$str preg_replace($replace,'',$str);
            
$str preg_replace($replace2,'',$str);
        }
            
$str preg_replace($replace,'${2}',$str);
            
$str preg_replace($replace2,'${2}',$str);
    }
    return 
$str;

ויש שם עוד כמה, פעם הבאה תעבור על התגובות שם, יש שם אחלה פונקציות שעוזרות המון
__________________
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 23:43.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ