Ver Mensaje Individual
  #8 (permalink)  
Antiguo 05/05/2007, 11:08
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Re: Remarcar palabras en una búsqueda

Probá esto (te repito la rta aquí por las dudas):
Código PHP:
<?php
if(!function_exists('str_ireplace')) {
function 
str_ireplace($search,$replace,$subject) {
$search preg_quote($search"/");
return 
preg_replace("/".$search."/i"$replace$subject); } } 

function 
resaltar($palabra$texto) {
        
$reemp=str_ireplace($palabra,'%s',$texto);
        
$ub=strpos($reemp,'%s');
        if(
$ub===false)return $texto;
        
$pal_original=substr($texto,$ub,strlen($palabra));
        return 
sprintf($reemp,'<strong>'.$pal_original.'</strong>');
    }
$str="Esto es una prueba de cómo se vería Youtube luego de aplicar la función";    
$test1=resaltar('YouTube'$str);
$test2=resaltar('Youtube'$str);
$test3=resaltar('youtube'$str);
echo 
$test1.'<br />'.$test2.'<br />'.$test3;
function 
palabraOriginal(){

}
?>