Jump to content

[SOLVED] str_replace


s_ainley87

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

Archived

This topic is now archived and is closed to further replies.

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