Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/03/2009, 15:20
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: str_ireplace() a str_replace()

Pues la diferencia entre str_replace y str_ireplace es que no es sensible a las mayusculas / minusculas, si requieres esa funcionalidad puedes usar esta implementación:
Código php:
Ver original
  1. if(!function_exists('str_ireplace')){
  2.   function str_ireplace($search,$replace,$subject){
  3.     $token = chr(1);
  4.     $haystack = strtolower($subject);
  5.     $needle = strtolower($search);
  6.     while (($pos=strpos($haystack,$needle))!==FALSE){
  7.       $subject = substr_replace($subject,$token,$pos,strlen($search));
  8.       $haystack = substr_replace($haystack,$token,$pos,strlen($search));
  9.     }
  10.     $subject = str_replace($token,$replace,$subject);
  11.     return $subject;
  12.   }
  13. }

Saludos.