code: private function replaceOnce($search, $replace, $subject)
      {
          $pos = strpos($subject, $search);
          if ($pos !== false) {
              $subject = substr_replace($subject, $replace, $pos, strlen($search));
          }
  
          return $subject;
      }
docs: Replace the first occurrence of a string
  
  @param  string $search
  @param  string $replace
  @param  string $subject
  @return mixed