Ver Mensaje Individual
  #9 (permalink)  
Antiguo 12/12/2005, 04:31
Avatar de DINASEN
DINASEN
 
Fecha de Ingreso: marzo-2003
Mensajes: 997
Antigüedad: 23 años, 7 meses
Puntos: 1
Nadie me puede ayudar a añadir este patron a este funcion ?
Patron :
Código PHP:
$busca = array("a","e","i","o","u", "ñ", "Ñ");  
    
$reemplaza = array("[aàáâãäåÀÁÂÃÄÅ]", "[eèéêëÈÉÊË]", "[iìíîïÌÍÎÏ]", "[oòóôõöÒÓÔÕÖ]", "[uùúûüÙÚÛÜ]", "[nñÑ]", "[nñÑ]");  
    
$needle = str_replace($busca, $reemplaza, $needle); 
funcion :
Código PHP:
<? 
    
function highlight_search($search_words,$string,$bgcolors='yellow') 
    { 
        if (
is_array($bgcolors)) { 
            
$no_colors=count($bgcolors); 
        } else { 
            
$temp=$bgcolors; 
            unset(
$bgcolors); 
            
$bgcolors[0]=$temp; 
            
$no_colors=1; 
        } 
        
$word_no=0; 
        foreach(
$search_words as $search_word) 
        { 
            
$regex1 = ">[^<]*("; 
            
$regex2 = ")[^<]*<"; 
            
preg_match_all("/".$regex1.$search_word.$regex2."/i", $string, $matches, PREG_PATTERN_ORDER); 
            foreach(
$matches[0] as $match) 
            { 
              
preg_match("/$search_word/i", $match, $out); 
              
$case_sensitive_search_word = $out[0]; 
              
$newtext = str_replace($case_sensitive_search_word,"<span style=\"background-color: ".$bgcolors[($word_no % $no_colors)].";\">$case_sensitive_search_word</span>", $match); 
              
$string = str_replace($match, $newtext, $string); 
            } 
            
$word_no++; 
        } 
        return 
$string; 
    } 

?>
Gracias

Un Saludo