<?php

$find   = "script"; // string to search
$new    = "##";     // string to replace
// text 
$string = "33onSCRIPTon oano AoKO k SCRIPT--atooto Atoto SCRIPTmoomo lko KOx0 lolo POpopo";


 function stripos2($string,$word){
  $retval   = false;
  $word_len = strlen($word);
  for($i=0;$i<=strlen($string);$i++){
   if (strtolower(substr($string,$i,$word_len)) == strtolower($word)){
    $retval[0] = true;
    $retval[1] = $i;
    $retval[2] = $word_len;
   }
  }
  return $retval;
 } 

 function striReplace( $string, $find, $new ){
  $r  = false;
  while( $p = stripos2( $string, $find ) ){
   if( $p[0] ){
    $r  = substr( $string, 0, $p[1] );
    $r .= $new;
    $r .= substr( $string, $p[1] + $p[2] );
   }
   $string = $r;
  }
  return $r;
 }

 echo 'original:<br />' . $string . '<hr>';

 echo striReplace( $string, $find, $new ); // mesmp resultado de str_ireplace http://php.net/str_ireplace
?>