vinpkl Posted December 20, 2008 Share Posted December 20, 2008 hi all i am generating a url dynamically in which <?php $cname= "Mobile Phones" ?> in the url i get Mobile%20Phones How can i replace %20 in it with - hyphen sign i have tried <?php $cname= "Mobile%20Phones" echo str_replace($cname,"%20","-"); ?> not able to get it work. how can i make it echo "Mobile-Phones" vineet Link to comment https://forums.phpfreaks.com/topic/137794-solved-string-replace-with-hyphen/ Share on other sites More sharing options...
MatthewJ Posted December 20, 2008 Share Posted December 20, 2008 <?php $cname= "Mobile-Phones" echo $cname; ?> Just kidding, but that was almost your example <?php $cname= "Mobile Phones" $cname = str_replace(" ", "-", $cname); echo $cname; ?> Link to comment https://forums.phpfreaks.com/topic/137794-solved-string-replace-with-hyphen/#findComment-720205 Share on other sites More sharing options...
vinpkl Posted December 20, 2008 Author Share Posted December 20, 2008 <?php $cname= "Mobile-Phones" echo $cname; ?> Just kidding, but that was almost your example <?php $cname= "Mobile Phones" $cname = str_replace(" ", "-", $cname); echo $cname; ?> hi MatthewJ thanks a lot. solved vineet Link to comment https://forums.phpfreaks.com/topic/137794-solved-string-replace-with-hyphen/#findComment-720206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.