Re: search/replace functions

From: Date: Wed, 03 Dec 2003 23:18:07 +0000
Subject: Re: search/replace functions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171747@lists.php.net to get a copy of this message
Scott -- ..and then Scott Ware said... % % I'm new to the list, and I don't want this to sound like a stupid ?, but % I am having an issue with a function that I created. No problem! % % I have some code stored in a database, similar to XML-style tags, but I % just created them myself to be more "user-friendly" to people. % Like for instance <bold></bold>, and <red></red> (would make the text % red). Nice of you :-) % % I created a function, to search on the tags that I made, and replace % them with the appropriate HTML ones, here is my function: [snip] Why, that looks almost exactly an example in the preg_replace() section of the manual :-) Have a read again. % for($i = 0; $i <= 31; $i++) % { % eregi_replace($search[$i], $replace[$i], $content); % } % % return $content; % } Try something like $content = preg_replace($search,$replace,$content) ; and enjoy. % .. % "$row_mysql_table['content']" output. Am I on the right track? And if % not, can anyone tell me how to accomplish this? The right track, I think, but don't bother with the loop. % % Thanks! HTH & HAND :-D -- David T-G * There is too much animal courage in (play) davidtg@justpickone.org * society and not sufficient moral courage. (work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#171747) next »