Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 19-09-03
lazy student
 
Join Date: Aug 2003
Posts: 362
Thanks: 0
Thanked 0 Times in 0 Posts
giveasyouget is an unknown quantity at this point
  Removing forward slashes / from a string in PHP

hey there.. been playing with mod_rewrite to make my pages more search engine friendly but some of the categories my script serves up contain the '/' character, which stops the server being able to find the script.

I've tried

$string=str_replace("/","",$string);

but it doesn't seem to do anything. Anybody got any ideas?
thanks,
jonny
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 19-09-03
lazy student
 
Join Date: Aug 2003
Posts: 362
Thanks: 0
Thanked 0 Times in 0 Posts
giveasyouget is an unknown quantity at this point
oh yes, and i've the same problem in a perl script should anyone be able to suggest the fix for that..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 19-09-03
loquax's Avatar
www.onelittleduck.co.uk
 
Join Date: Aug 2003
Location: Swansea
Posts: 2,513
Thanks: 13
Thanked 29 Times in 17 Posts
loquax seems to know their stuff
Try

http://www.zend.com/manual/function.stripslashes.php

echo stripslashes($str);

Jason
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 19-09-03
ianm's Avatar
Avoiding real work
 
Join Date: Aug 2003
Location: Buckinghamshire
Posts: 1,382
Thanks: 0
Thanked 0 Times in 0 Posts
ianm is an unknown quantity at this point
stripslashes probably won't work - it removes the \ character not the /.

There's no reason why
PHP Code:
$string=str_replace("/","",$string); 
shouldn't work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 19-09-03
ianm's Avatar
Avoiding real work
 
Join Date: Aug 2003
Location: Buckinghamshire
Posts: 1,382
Thanks: 0
Thanked 0 Times in 0 Posts
ianm is an unknown quantity at this point
Just though why it might not work - the / probably needs to be escaped, so try -

PHP Code:
$string=str_replace("\\/","",$string); 
and the same possibly goes for Perl - I think its something to do with regular expressions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 19-09-03
lazy student
 
Join Date: Aug 2003
Posts: 362
Thanks: 0
Thanked 0 Times in 0 Posts
giveasyouget is an unknown quantity at this point
hmm yeah that's what i thought. I fixed the prob in perl - I had to use \/ not / but it doesn't seem to work in php for some reason..


....ug sorry im being a right muppet, doing the str_replace in a different bit of code to the one displaying the link! tsk tsk.. well thanku everyone all the same!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 19-09-03
Super Moderator
 
Join Date: Aug 2003
Posts: 2,451
Thanks: 0
Thanked 0 Times in 0 Posts
Rich is an unknown quantity at this point
One thing for the future, try using single quotes (') rather than double ('') as php doesn't check for escape chars etc in single quoted strings. It also doesn't check for inserted variables, so single quoted strings are quicker if you don't need then.

e.g.
Code:
<?
$val='hello';
echo "$val world\n";
echo '$val world\n';
?>
Would print: -
Code:
Hello World
$val world\n
(\n is a new-line character)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone anygood with xml, php, mysql and Affiliate Window AnnonnyMouse The Affiliate Marketing Lounge 1 23-09-04 11:00 AM
php: find string length morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 2 25-06-04 11:47 AM
how to shorten a string (php) morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 27-03-04 05:35 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7