egturnkey Posted November 22, 2010 Share Posted November 22, 2010 Hello friends, If we have link $x = "search engin"; <a href="google.com"><?=$x?></a> and we want to remove space btween (search engine) to be (search-engine) ineed we should use str_replace and we change the link to $manal = str_replace(" ", "-", trim($x)); <a href="google.com"><?=$manal?></a> It not working ? and only working if $manal = str_replace(" ", "+", trim($x)); why + not - ? and is there anyway else to replce space to - ? thanks Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 22, 2010 Share Posted November 22, 2010 works fine for me <?php $x = "search engin"; $manal = str_replace(" ", "-", trim($x)); ?> <a href="google.com"><?php echo $manal; ?></a> Quote Link to comment Share on other sites More sharing options...
egturnkey Posted November 22, 2010 Author Share Posted November 22, 2010 i found the reason ! my example above it very simple but the real one has keyword-ID and if the keywords = x y z and i replace space with - so the link will be x-y-z-ID <-- works but for .htaccess RewriteRule -(.*)\.htm view.php?id=$1 <--- will not work RewriteRule _(.*)\.htm view.php?id=$1 <--- will work so the link will be x-y-z_ID <--- Fine enough Now another quetions please what for multi-str replace i mean if i've $x= "I love?world"; i want replce both spaces and ? with - so it be I-love-world r_replace(array(" ","?"), "-", trim($x)); <-- it is right Quote Link to comment 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.