mcloan Posted December 2, 2006 Share Posted December 2, 2006 Can anyone tell me the best way to remove the + from $city=Apple+Valley so that $city become $city=Apple Valley ?Thank you! Link to comment https://forums.phpfreaks.com/topic/29239-best-way-to-remove-a-character-from-a-string-and-replace-with-a-space/ Share on other sites More sharing options...
AndyB Posted December 2, 2006 Share Posted December 2, 2006 str_replace() Link to comment https://forums.phpfreaks.com/topic/29239-best-way-to-remove-a-character-from-a-string-and-replace-with-a-space/#findComment-134040 Share on other sites More sharing options...
mcloan Posted December 2, 2006 Author Share Posted December 2, 2006 [quote author=AndyB link=topic=117126.msg477620#msg477620 date=1165084611]str_replace()[/quote]You mind providing an example? I tried this function and could not get it to work.Thank you. Link to comment https://forums.phpfreaks.com/topic/29239-best-way-to-remove-a-character-from-a-string-and-replace-with-a-space/#findComment-134042 Share on other sites More sharing options...
AndyB Posted December 2, 2006 Share Posted December 2, 2006 The manual is full of examples :)[code]<?php$city = "Apple+Valley";$city1 = str_replace("+"," ",$city);echo $city. " -> ". $city1;?>[/code] Link to comment https://forums.phpfreaks.com/topic/29239-best-way-to-remove-a-character-from-a-string-and-replace-with-a-space/#findComment-134045 Share on other sites More sharing options...
.josh Posted December 2, 2006 Share Posted December 2, 2006 www.php.net/yourfunctionhereexample:www.php.net/str_replace Link to comment https://forums.phpfreaks.com/topic/29239-best-way-to-remove-a-character-from-a-string-and-replace-with-a-space/#findComment-134046 Share on other sites More sharing options...
mcloan Posted December 2, 2006 Author Share Posted December 2, 2006 Thank you, I did check the manual, but I am a bit new to programming and was a bit confused by the examples becasue they were mostly using arrays.Thank you again your simplified version worked perfect and now I think I have the concept... :) Link to comment https://forums.phpfreaks.com/topic/29239-best-way-to-remove-a-character-from-a-string-and-replace-with-a-space/#findComment-134051 Share on other sites More sharing options...
kenrbnsn Posted December 2, 2006 Share Posted December 2, 2006 You can also use [url=http://www.php.net/urldecode]urldecode()[/url]Ken Link to comment https://forums.phpfreaks.com/topic/29239-best-way-to-remove-a-character-from-a-string-and-replace-with-a-space/#findComment-134115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.