0

I have a page that is calling dynamic URL content from MySQL via Primary ID. The information is being called and echoed as

"../images/icons/filename.jpg"

via this command:

<php echo $row_getimages['icon']; ?>

I want to change "../images/icons/filename.jpg" to:

"http://www.mysite.com/images/icons/filename.jpg"

Does anyone know if this is possible with a str_replace or some other command? I have tried that particular one but I am having trouble figuring out the proper syntax.

1
  • Can you show the exact code you have tried? Would help us help you.. Commented Nov 28, 2012 at 18:07

2 Answers 2

1

Try

<?php echo str_replace('../','http://www.mysite.com/',$row_getimages['icon']); ?>
Sign up to request clarification or add additional context in comments.

Comments

0

Yes you can user str_replace():

<?php echo str_replace("../","http://www.mysite.com/",$row_getimages['icon']); ?>

Just make sure you have the parameters in the correct order:

1 Comment

Worked like a charm, it was just my order that was fudging me up. Thank you very much for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.