public function replaceText($search, $replace)
    {
        if (!$this->open('r+')) {
            return false;
        }

        if ($this->lock !== null && flock($this->handle, LOCK_EX) === false) {
            return false;
        }

        $replaced = $this->write(str_replace($search, $replace, $this->read()), 'w', true);

        if ($this->lock !== null) {
            flock($this->handle, LOCK_UN);
        }
        $this->close();

        return $replaced;
    }
public function replaceText($search, $replace)
    {
        if (!$this->open('r+')) {
            return false;
        }

        if ($this->lock !== null && flock($this->handle, LOCK_EX) === false) {
            return false;
        }

        $replaced = $this->write(str_replace($search, $replace, $this->read()), 'w', true);

        if ($this->lock !== null) {
            flock($this->handle, LOCK_UN);
        }
        $this->close();

        return $replaced;
    }
public function replaceText ( $ search , $ replace ) { if ( ! $ this -> open ( 'r+' ) ) { return false ; } if ( $ this -> lock !== null && flock ( $ this -> handle , LOCK_EX ) === false ) { return false ; } $ replaced = $ this -> write ( str_replace ( $ search , $ replace , $ this -> read ( ) ) , 'w' , true ) ; if ( $ this -> lock !== null ) { flock ( $ this -> handle , LOCK_UN ) ; } $ this -> close ( ) ; return $ replaced ; }
Searches for a given text and replaces the text if found.

@param string|array $search Text(s) to search for.
@param string|array $replace Text(s) to replace with.
@return bool Success
Searches for a given text and replaces the text if found .