tags:

views:

53

answers:

4

Hey Friends,
I am using the following API for getting details of IMDB,http://www.deanclatworthy.com/imdb/?q=Star+Trek
while i using following API i am getting URL as following Output

http:\/\/www.imdb.com\/title\/tt0796366\/

how can i change it to

http://www.imdb.com/title/tt0796366/

in PHP?

+5  A: 

Use stripslashes:

$url = 'http:\/\/www.imdb.com\/title\/tt0796366\/';
$url = stripslashes($url);
Emil Vikström
A: 
$url = "http:\/\/www.imdb.com\/title\/tt0796366\/";
$url = str_replace("\/","/",$url);

example here http://ideone.com/J44Q6

seengee
strange that this got downvoted since it works (see above) - not saying its the best solution but its a different one
seengee
A: 

$url = str_replace('\', '', $url);

Jan Wy
A: 

The URL has been escaped - that is, it has had a back-slash character added in front of certain other characters which could cause issues, eg if they were put into a SQL string.

PHP has a command stripslashes() to remove these escape characters.

However, the feature of PHP adding the slashes automatically is old and is now deprecated. If possible, you should check your PHP.ini and turn off the magic_quotes option. That way you won't get the slashes added to your input any more, so you won't have to remove them.

Note that if you are writing data to a database, you will need to escape it before putting it in your SQL string. But you should use something like mysql_real_escape_string() instead of the slashes added by magic_quotes.

Spudley