s_ainley87 Posted July 28, 2008 Share Posted July 28, 2008 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 More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 str_replace('[iMAGEPATH]', 'http://www.myurl/image/myimage.gif', $variableHoldingYourPageInfo); ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/116961-solved-str_replace/#findComment-601460 Share on other sites More sharing options...
s_ainley87 Posted July 28, 2008 Author Share Posted July 28, 2008 Thanks that has really helped what if I wanted to replace the link the sits 'behind' the image? would I have to right that into PHP and do str replace with a link init? How would I do that? Link to comment https://forums.phpfreaks.com/topic/116961-solved-str_replace/#findComment-601493 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 I don't understand the question. Give me an example please? ---------------- Now playing: Enter Shikari - The Feast (Demo) via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/116961-solved-str_replace/#findComment-601497 Share on other sites More sharing options...
s_ainley87 Posted July 28, 2008 Author Share Posted July 28, 2008 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 More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 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 More sharing options...
s_ainley87 Posted July 28, 2008 Author Share Posted July 28, 2008 thanks Link to comment https://forums.phpfreaks.com/topic/116961-solved-str_replace/#findComment-601510 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 No worries if it works, remember to click topic solved! ---------------- Now playing: Enter Shikari - Adieu (Routron 5000 Remix) via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/116961-solved-str_replace/#findComment-601511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.