Jump to content

str_replace help


ShaolinF

Recommended Posts

Hi Guys

I am using str_replace to remove userdefined code and replace it with the HTML equivalent. So for example:

 

will be replaced with <strong></strong>.

 

I have come across a problem with

tags. The problem is the opening quote tag has the name of the person after the equals sign. For example:
- How can I replace this type of tag to something like:

 

<div class="odd"><span>Jo</span>

 

I cant do this with str_replace as it takes a static input whereas the opening quote tag is dynamic and subject to change (or atleast the name is).

 

 

Link to comment
https://forums.phpfreaks.com/topic/199002-str_replace-help/
Share on other sites

Hi Guys

I am using str_replace to remove userdefined code and replace it with the HTML equivalent. So for example:

 

will be replaced with <strong></strong>.

 

I have come across a problem with

tags. The problem is the opening quote tag has the name of the person after the equals sign. For example:
- How can I replace this type of tag to something like:

 

<div class="odd"><span>Jo</span>

 

I cant do this with str_replace as it takes a static input whereas the opening quote tag is dynamic and subject to change (or atleast the name is).

 

you could use strpos on both the author= and link= to find the position that encompasses the posters name and then set that in a variable. From there construct your string. There are probably many other ways to do it but that was the first that popped in my head. String manipulation is fun :)

Link to comment
https://forums.phpfreaks.com/topic/199002-str_replace-help/#findComment-1044555
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.