David Nelson Posted April 13, 2008 Share Posted April 13, 2008 Hi guys, I have a form which submits the content of an input box into the next page where it is called numerous times, in one instance, though, it will need to substitute and spaces inputted with an underscore (_) Could I please get a code snippet to do this? Thanks! Link to comment https://forums.phpfreaks.com/topic/100863-substitute-spaces-with-_/ Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 <?php str_replace("","_",$string);?> Link to comment https://forums.phpfreaks.com/topic/100863-substitute-spaces-with-_/#findComment-515807 Share on other sites More sharing options...
David Nelson Posted April 13, 2008 Author Share Posted April 13, 2008 Thanks. I'm really basic here.... (as you can tell) <?php echo ''.$artist; ?> That is what I've got right now, to call my inputted text from the previous page. So, how would I incorporate str_replace("","_",$string); into that? Forgive my n00b-ness. Link to comment https://forums.phpfreaks.com/topic/100863-substitute-spaces-with-_/#findComment-515809 Share on other sites More sharing options...
darkfreaks Posted April 13, 2008 Share Posted April 13, 2008 well replace $string with $artist and it will remove all spaces and turn them into underscores if thats what you want ??? Link to comment https://forums.phpfreaks.com/topic/100863-substitute-spaces-with-_/#findComment-515811 Share on other sites More sharing options...
AndyB Posted April 13, 2008 Share Posted April 13, 2008 $artist1 = str_replace(" ","_",$artist);// revised var with underscores Link to comment https://forums.phpfreaks.com/topic/100863-substitute-spaces-with-_/#findComment-515814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.