note 36809 deleted from ref.strings by aidan

From: Date: Sun, 15 Aug 2004 13:48:19 +0000
Subject: note 36809 deleted from ref.strings by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74703@lists.php.net to get a copy of this message
Note Submitter: thewolf at pixelcarnage dot com ---- I got sick of trying to replace just a word, so I decided I would write my own string replacement code. When that code because far to big and a little faulty I decided to use a simple preg_replace: function word_replace($search, $replace, $subject) { /*------------------------------------------------------- Written by Rowan Lewis of PixelCarnage.com --------------------------------------------------------- $search(string), the string to be searched for $replace(string), the string to replace $search $subject(string), the string to be searched in -------------------------------------------------------*/ return preg_replace('/[a-zA-Z]+/e', '\'\0\' == \'' . $search . '\' ? \'' . $replace . '\': \'\0\';', $subject); } I hope that this code helpes someone!

« previous php.notes (#74703) next »