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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.