Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

How to string replace

Participant ,
Mar 28, 2013 Mar 28, 2013

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

TOPICS
Server side applications
580
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 28, 2013 Mar 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 29, 2013 Mar 29, 2013
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines