הרשם שאלות ותשובות רשימת חברים לוח שנה חיפוש הודעות מהיום סמן פורומים כנקראו

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 08-10-10, 15:14   # 1
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. הזמן כעת הוא 18:54.

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