Metehan: php-Funktion wordwrap()

Beitrag lesen

Danke für die wirklich guten Lösungsansätze. Eine vollumfängliche Interpretation und Umsetzung wird aber für mich einige Zeit in Anspruch nehmen. Daher wäre ich schon verbunden, zumindest für diese Problemstellung eine Optimierung vorgeschlagen zu bekommen, sofern nicht zuviel verlangt. Ansonsten trotzdem vielen Dank. nachfolgend der kompl. Codeabschnitt.

            // email encoding to stop harvesters  
            $ShoutPart = bin2hex($ShoutPart);  
            $ShoutPart = chunk_split($ShoutPart, 2, '%');  
            $ShoutPart = '%' . substr($ShoutPart, 0, strlen($ShoutPart) - 1);  
            $ShoutNew[$i] = "&#91;<a href=\"mailto:$ShoutPart\">E-Mail</a>&#93;";  
        } elseif ((eregi("\.(us|tv|cc|ws|ca|de|jp|ro|be|fm|ms|tc|ph|dk|st|ac|gs|vg|sh|kz|as|lt|to)", substr("$ShoutPart", -3, 3))) OR (eregi("\.(com|net|org|mil|gov|biz|pro|xxx)", substr("$ShoutPart", -4, 4))) OR (eregi("\.(info|name|mobi)", substr("$ShoutPart", -5, 5))) OR (eregi("\.(co\.uk|co\.za|co\.nz|co\.il)", substr("$ShoutPart", -6, 6)))) {  
            if ($conf['urlonoff'] == "no") {  
                $ShoutError = _URLNOTALLOWED;  
                return false;  
            }  
            $ShoutPart = "http://" . $ShoutPart;  
            $ShoutNew[$i] = "&#91;<a rel=\"nofollow\" target=\"_blank\" href=\"$ShoutPart\">URL</a>&#93;";  
        } elseif (strlen(html_entity_decode($ShoutPart, ENT_QUOTES)) > 21) {  
            $ShoutNew[$i] = htmlspecialchars(wordwrap(html_entity_decode($ShoutPart, ENT_QUOTES), 21, " ", 1), ENT_QUOTES);  
  
            $ShoutNew[$i] = str_replace("[ b]", " [b]", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[b ]", " [b]", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[ /b]", "[/b] ", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[/ b]", "[/b] ", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[/b ]", "[/b] ", $ShoutNew[$i]);  
  
            $ShoutNew[$i] = str_replace("[ i]", " [i]", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[i ]", " [i]", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[ /i]", "[/i] ", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[/ i]", "[/i] ", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[/i ]", "[/i] ", $ShoutNew[$i]);  
  
            $ShoutNew[$i] = str_replace("[ u]", " [u]", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[u ]", " [u]", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[ /u]", "[/u] ", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[/ u]", "[/u] ", $ShoutNew[$i]);  
            $ShoutNew[$i] = str_replace("[/u ]", "[/u] ", $ShoutNew[$i]);  
        } else {  
            $ShoutNew[$i] = $ShoutPart;  
        }  
        $i++;  
    }