-3

"image_url":"\"http://gfgfgfg.com/wjjjj/kjjk/2014/08/LOGO-1024x1024.jpg\""

I had the above result in json response, but it shows \" in front and back of the url. I just want to remove it from the result.

I saw the .gsub() in Ruby, but I want to remove \" using PHP. str_replace('\"','',$string) does not working :

 $image_rul=trim(str_replace(array('=','\"'), '', $i_url));
halfer
  • 19,824
  • 17
  • 99
  • 186
PHP Learner
  • 111
  • 2
  • 4
  • 15

2 Answers2

3

Use this,

$var = '"image_url":"\"http://gfgfgfg.com/wjjjj/kjjk/2014/08/LOGO-1024x1024.jpg\""';
$result =  str_replace('\"','',$var);

Result = "image_url":"http://gfgfgfg.com/wjjjj/kjjk/2014/08/LOGO-1024x1024.jpg"

    $var = '"image_url":"\"http://gfgfgfg.com/wjjjj/kjjk/2014/08/LOGO-1024x1024.jpg\""';
    $result =  str_replace('\\','',$var);
    echo $result =  str_replace('"','',$result);

result = image_url:http://gfgfgfg.com/wjjjj/kjjk/2014/08/LOGO-1024x1024.jpg

halfer
  • 19,824
  • 17
  • 99
  • 186
alagu
  • 586
  • 1
  • 4
  • 12
1

You can use stripslashes for this purpose.

See this for more clarification.

halfer
  • 19,824
  • 17
  • 99
  • 186
Avinash Babu
  • 6,171
  • 3
  • 21
  • 26