egturnkey Posted March 13, 2010 Share Posted March 13, 2010 hello dear friends, Let say i have something called name $name = "i love phpfread"; and say i have a link $URL = "http://something/$name"; so now the url will be shown like this http://something/i love phpfread how i can make like this http://something/i-love-phpfread see (-) btween each word does it needs a command at .htaccess !! Link to comment https://forums.phpfreaks.com/topic/195095-add-to-the-name-btween-words/ Share on other sites More sharing options...
teamatomic Posted March 13, 2010 Share Posted March 13, 2010 $name = "i love phpfread"; $name=str_replace(" ", "-",$name); HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/195095-add-to-the-name-btween-words/#findComment-1025538 Share on other sites More sharing options...
watsmyname Posted March 13, 2010 Share Posted March 13, 2010 I dont think url http://something/i-love-phpfread this will lead you to any where unless you have folder "i-love-phpfread" or filename i-love-phpfread.html or i-love-phpfread.php in the domain "something". but seeing stuffs, i think you want to use url rewriting. just replacing blank space with "-" wont let you anywhere. Again if you want to use url rewriting, then what if $name="A's best php theory/practice book" or similar?? for these kind of texts you have to use regex pattern. Link to comment https://forums.phpfreaks.com/topic/195095-add-to-the-name-btween-words/#findComment-1025540 Share on other sites More sharing options...
Rustywolf Posted March 13, 2010 Share Posted March 13, 2010 I dont think url http://something/i-love-phpfread this will lead you to any where unless you have folder "i-love-phpfread" or filename i-love-phpfread.html or i-love-phpfread.php in the domain "something". but seeing stuffs, i think you want to use url rewriting. just replacing blank space with "-" wont let you anywhere. Again if you want to use url rewriting, then what if $name="A's best php theory/practice book" or similar?? for these kind of texts you have to use regex pattern. or mod_rewrite. Link to comment https://forums.phpfreaks.com/topic/195095-add-to-the-name-btween-words/#findComment-1025544 Share on other sites More sharing options...
egturnkey Posted March 13, 2010 Author Share Posted March 13, 2010 @teamatomic thanks it works perfect @watsmyname Yes, i know and i just mention an example and indeed i've made changes in .htaccess to fit with the changes and i've test it and works perfect @Rustywolf Indeed that was the idea, i made the change in the main $Url then changes in .htaccess thanks you all for your replies it was helpfull to me . Link to comment https://forums.phpfreaks.com/topic/195095-add-to-the-name-btween-words/#findComment-1025547 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.