<? // Retorna o "$haystack" modificado. function replaceFirst($find, $replacement, $haystack){ $myPos = strpos($haystack,$find); if ($myPos<0){ // needle not found return $haystack; }else{ //found the needle return substr_replace($haystack,$replacement,$myPos,strlen($find)); } } // use do mesmo jeito que vc usaria o str_replace(). ?>