dazzclub Posted March 27, 2009 Share Posted March 27, 2009 Hello I am trying to replace two html characters from my string one and one ® with white space and the other no white space. ie. from fast cars.gif to fast cars.gif and from porsche®.gif to porsche.gif is it possible? Here us what i have go so far; $no_reg= ''; $dirty = array(' ','®' ); $clean = array (' ', ''); echo '<h5><img src="headerbars/'.str_replace(' ', ' ',$row['SubCatName']).'.gif" title="" alt="" style="position:absolute;top:12em;left:19em;border:none;"/></h5>'; I tried to set up two arrays, one with the problem and the other with the solution, but i am getting stuck. any pointers woud be great Quote Link to comment https://forums.phpfreaks.com/topic/151385-solved-str_replace-question/ Share on other sites More sharing options...
Adam Posted March 27, 2009 Share Posted March 27, 2009 Have you tried.. str_replace($dirty, $clean, $row['SubCatName']) ?? Adam Quote Link to comment https://forums.phpfreaks.com/topic/151385-solved-str_replace-question/#findComment-795120 Share on other sites More sharing options...
Yesideez Posted March 27, 2009 Share Posted March 27, 2009 Replace the $clean=str_replace(' ',' ',$dirty); Replace the ® $clean=str_replace('®','',$dirty); In your code you're not using $clean and $dirty: echo '<h5><img src="headerbars/'.str_replace($clean,$dirty,$row['SubCatName']).'.gif" title="" alt="" style="position:absolute;top:12em;left:19em;border:none;"/></h5>'; Quote Link to comment https://forums.phpfreaks.com/topic/151385-solved-str_replace-question/#findComment-795122 Share on other sites More sharing options...
dazzclub Posted March 27, 2009 Author Share Posted March 27, 2009 lol, i tried that but left the "" instead, so it looked like this, '.str_replace('$dirty', '$clean', $row['SubCatName']).' thanks for pointing that out. Quote Link to comment https://forums.phpfreaks.com/topic/151385-solved-str_replace-question/#findComment-795129 Share on other sites More sharing options...
Adam Posted March 27, 2009 Share Posted March 27, 2009 Remove the quotes from around your arrays... A Quote Link to comment https://forums.phpfreaks.com/topic/151385-solved-str_replace-question/#findComment-795206 Share on other sites More sharing options...
Yesideez Posted March 27, 2009 Share Posted March 27, 2009 That's what he did but not before it was pointed out Quote Link to comment https://forums.phpfreaks.com/topic/151385-solved-str_replace-question/#findComment-795267 Share on other sites More sharing options...
Adam Posted March 27, 2009 Share Posted March 27, 2009 Ahhh yeahh! I don't think I made sense of it first time I read it! Quote Link to comment https://forums.phpfreaks.com/topic/151385-solved-str_replace-question/#findComment-795270 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.