Manoj
Manoj

Reputation: 9

String Replace Not Working

I am getting a value through Query string but facing some problem in printing that value

The query string is

http://mastertrade.in/master/wpfiles/corp_announcements.php?tpnt=5544&caption=%22KNRCON%20-%20Press%20Release%22

Then I am getting the caption with GET method like this

$cap=$_GET['caption'];

While print this Variable $cap am getting this

\"KNRCON - Press Release\"

I dont want

\

while print what should I do ? I tried

preg_replace('/\/','',$cap);

But I am getting

 preg_replace() [function.preg-replace]: No ending matching delimiter '/' 

Upvotes: 0

Views: 176

Answers (3)

dfsq
dfsq

Reputation: 193261

Nice answers. But noone suggested just to turn Magic Quotes off. Or use get_magic_quotes_gpc/. http://www.php.net/manual/en/function.get-magic-quotes-gpc.php

$caption = $_GET['caption'];
if (get_magic_quotes_gpc()) {
    $caption = stripslashes($caption);
}

Upvotes: 1

rauschen
rauschen

Reputation: 3996

There is a function to remove the escape slashes stripslashes

$cap = stripslashes($cap);

Upvotes: 2

Zul
Zul

Reputation: 3608

<?php
$string = '\"KNRCON - Press Release\"';    
echo str_replace(array('\/','\\'),'',$string);  //Output: "KNRCON - Press Release"
?>

Upvotes: 0

Related Questions