Skip to main content
Inspiring
March 28, 2013
Question

How to string replace

  • March 28, 2013
  • 1 reply
  • 624 views

Hi,

I hope somebody can help me with this.

I try to replace a string in the body of a php page to automaticaly insert rel='lightbox[serie] to make lightbox work while inserting photos within TinyMCE.

I created this code in the head section but it doesnot work:

<?php $imagetag = str_replace("<img", "<img rel='lightbox[serie]'", "<body>"); ?>

Where do I go wrong?

Your help is appreciated.

Jos

This topic has been closed for replies.

1 reply

Participating Frequently
March 28, 2013

str_replace takes 3 mandatory parameters

search = the string your are search for = "<img"

replace = the string you want to replace it with =  "<img rel='lightbox[serie]'"

subject = the string or array you want to search = "<body>"

For subject, you are using a hard coded string which does not make sense because the string "<body>" does not contain the string "<img". You need to supply a string variable that contains the string you are searching for.

Inspiring
March 29, 2013

Thanks for reaction. I will let you know if I succeed.