Jump to content

Recommended Posts

Hello, I am struggling with working how to construct the str_replace function,

 

What I currently have is a controllerpage full of functions that controls linked images and which URL they link too and where the images are pulled from, what I want is depening on the session id for the image to be pulled from a certain URL, so I want to replace this [iMAGEPATH] with this http://www.myurl/image/myimage.gif, how would I construct that in str_replace?

 

Thanks everyone

 

s_ainley87

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

i currently have in my html document,

 

 

a href="go.html">[iMAGEPATH]

 

 

and in my php controller i have

 

($session = new Zend_Session_Namespace('Zend_Auth');
if($session = something) {
str_replace('[iMAGEPATH]', 'http://www.myurl/image/myimage.gif', $variableHoldingYourPageInfo);
} else {
//do normal [iMAGEPATH]
}

 

what I am saying is that if i want the image that is replacing the original image to link somewhere else will i have to put the whole thing in str_replace including the link and how would i do it?

Link to comment
https://forums.phpfreaks.com/topic/116961-solved-str_replace/#findComment-601503
Share on other sites

Ooh I see. you would simply change the second argument:

 

str_replace('[iMAGEPATH]', '<a href="path/to/file.php"><img src="http://www.myurl/image/myimage.gif" /></a>', $variableHoldingYourPageInfo);

 

----------------

Now playing: Enter Shikari - Keep It On Ice

via FoxyTunes

Link to comment
https://forums.phpfreaks.com/topic/116961-solved-str_replace/#findComment-601504
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.