-4

I have an image src as :

https://scontent.xx.fbcdn.net/hphotos-xtl1/v/t1.0-9/s720x720/10291693_1478919849038582_6717876706471049180_n.jpg?oh=0e2416fd3373c0757b7f3dd40169dfa9&oe=57127C81

it contains symbol '&' i need to use url without '&' symbol.

I tried urlencode but it returns:

https%3A%2F%2Fscontent.xx.fbcdn.net%2Fhphotos-xtl1%2Fv%2Ft1.0-9%2Fs720x720%2F10291693_1478919849038582_6717876706471049180_n.jpg%3Foh%3D0e2416fd3373c0757b7f3dd40169dfa9%26oe%3D57127C81

Doesn't work.

I also tried to replace '&' with '%26'

https://scontent.xx.fbcdn.net/hphotos-xtl1/v/t1.0-9/s720x720/10291693_1478919849038582_6717876706471049180_n.jpg?oh=0e2416fd3373c0757b7f3dd40169dfa9%26oe=57127C81

But no success. Any help?

Mage
  • 1
  • 1
  • 1
    _“i need to use url without '&' symbol”_ – why? In what context? How is the `&` a problem? – CBroe Dec 18 '15 at 07:53
  • Because i have something like – Mage Dec 18 '15 at 08:46
  • when i tried to access that imgsrc as $_REQUEST['imgsrc'] it exclude string after '&' symbol. i hope you got it. – Mage Dec 18 '15 at 08:47
  • So you want to pass that URL as a parameter value inside another URL? Then of course you need to URL-encode it properly. – CBroe Dec 18 '15 at 11:36

1 Answers1

0

Just remove everything after "&", for example:

$variable = substr($variable, 0, strpos($variable, '&'));

Source: Remove portion of a string after a certain character

Community
  • 1
  • 1
andyrandy
  • 72,880
  • 8
  • 113
  • 130