cmb Posted April 8, 2012 Share Posted April 8, 2012 all i want is for when their is a _ to be replaced with a space so i tried these and neither worked <?php $pmod = str_replace("_"," ",$p); $pmod = preg_replace("_"," ",$p); ?> so i was wondering if because this was in a while statement, is this the reason its not working, and if so how should i fix it (this is the while) <?php while ($z <= $w){ $p = $multi[$z]; $pmod = str_replace("_"," ",$p); echo "<a href='tag.php?tag=$p'" . $p . ">" . $pmod . "</a> "; $z++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/260541-character-replaceing/ Share on other sites More sharing options...
trq Posted April 8, 2012 Share Posted April 8, 2012 Having it within a loop makes no difference. What is the issue you are having? Quote Link to comment https://forums.phpfreaks.com/topic/260541-character-replaceing/#findComment-1335303 Share on other sites More sharing options...
cmb Posted April 8, 2012 Author Share Posted April 8, 2012 its not replacing the _ with a space Quote Link to comment https://forums.phpfreaks.com/topic/260541-character-replaceing/#findComment-1335304 Share on other sites More sharing options...
trq Posted April 8, 2012 Share Posted April 8, 2012 Show us what is being output. Quote Link to comment https://forums.phpfreaks.com/topic/260541-character-replaceing/#findComment-1335306 Share on other sites More sharing options...
cmb Posted April 8, 2012 Author Share Posted April 8, 2012 this is what its out putting <a href='tag.php?tag=Ryan_S'Ryan_S>Ryan_S</a></div></div></li><li> also i don't think this is important but i am using this in the gallerific jquery plugin Quote Link to comment https://forums.phpfreaks.com/topic/260541-character-replaceing/#findComment-1335310 Share on other sites More sharing options...
trq Posted April 8, 2012 Share Posted April 8, 2012 That code could not possibly output those results. OT, your echo line is making an invalid link, it should be: echo "<a href='tag.php?tag=$p'>" . $pmod . "</a> "; Quote Link to comment https://forums.phpfreaks.com/topic/260541-character-replaceing/#findComment-1335313 Share on other sites More sharing options...
cmb Posted April 8, 2012 Author Share Posted April 8, 2012 WOW im stupid i forgot that this was also in an if statement and i only corrected the one part instead of both thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/260541-character-replaceing/#findComment-1335316 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.