Hi,
I hope someones come across this problem. The problem is everytime php see's a apostophe (their's) it automatically adds a backslash to it. I was hoping if anyone had a function to remove all the backslashes from a given sentance.
I have written a little snippet of code and was hoping if someone could have a look and see where i'm going wrong.
THANKS.
<ALL HELP APPRECIATED>
Here's my code below:
<?php
//Remove all backslash
$address="hello worl'd";
$n = strlen($address);
for($i=0; $i<$n; $i++)
If substr("$address","$i","$i", <> "\") //then
{
substr($address);
}
?>
A php function for removing "\" from a sentence ??
Moderator: General Moderators
-
capesystem
- Forum Newbie
- Posts: 1
- Joined: Wed Jul 22, 2009 10:10 am
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: A php function for removing "\" from a sentence ??
Look to the stripslashes() function and make sure you know the setting for magic quotes
-
UnknownOne
- Forum Newbie
- Posts: 5
- Joined: Thu Jul 23, 2009 8:52 am
Re: A php function for removing "\" from a sentence ??
Could we not use the str_replace() function here?
I've only just started off and not sure how exactly to get the str_replace function working but I should do with a little research.
Something like:
I'm not exactly sure as I'm not too clear on it myself.
Anyone care to help out capesystem and myself?
Thanks in advance for any responses. =)
I've only just started off and not sure how exactly to get the str_replace function working but I should do with a little research.
Something like:
Code: Select all
str_replace("/", "", "the location?");
//First quote should identify what should be replaced
//second quote should identify what it should be replaced by
//Third and final quote should identify the location of the string?Anyone care to help out capesystem and myself?
Thanks in advance for any responses. =)
Re: A php function for removing "\" from a sentence ??
you could, but I'm sure your issue is (as Mark pointed out) with magic_quotes_gpc and not using stripslashes(). Turn off magic quotes and use stripslashes().