[thelist] Please help.. PHP guru's
John williams
thudfactor at gmail.com
Thu Feb 24 08:10:39 CST 2005
I think you could use str_replace (which isn't regular expressions):
str_replace(searchstr,replacestr,subjectstr) (returns modified string)
$subject_string = str_replace('<?','<?',$subject_string);
$subject_string = str_replace('?>','?>',$subject_string);
If you go with reg_ex, besides taking a little longer you're going to
have to quote out questionmarks, etc.
You can also pass str_replace arrays for parameters 1 and 2.
$replace_me = array('<?','?>');
$with_me = array('<?','?>');
$subject_string = str_replace($replace_me,$with_me,$subject_string);
More info (and maybe better examples) at http://us4.php.net/str_replace
On Thu, 24 Feb 2005 23:27:08 +1030, Tim Burgan <email at timburgan.com> wrote:
> Hello,
>
> I have a string:
> $str = '<p>This is a paragraph<p><?php echo \'hello\';
> ?>';
>
> Which I convert using:
> html_entity_decode(stripslashes($str));
>
> Which result in:
> <p>This is a paragraph</p><?php echo 'hello'; ?>
>
> But.. I need to manipulate the string in such a way that the PHP tags to
> STAY ENCODED like:
> <p>This is a paragraph</p><?php echo 'hello'; ?>
>
> How do I do this..? Would I use regular expressions, but how?
>
> Thanks
>
> Tim
>
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
More information about the thelist
mailing list