0

I need to sub-string the value within some special character using PHP. I am showing the original string below.

"name=G%20+%20l&cid=20"

In the above string I need the value within name= to next &.

halfer
  • 19,824
  • 17
  • 99
  • 186
satya
  • 3,508
  • 11
  • 50
  • 130

1 Answers1

1

Try this:

$string = "name=G%20+%20l&cid=20";
$explode_string = explode("&", $string);

$explode_string2 = explode("name=", $explode_string[0]);
echo array_pop($explode_string2);

Output will be like:

G%20+%20l
Mahesh Singh Chouhan
  • 2,558
  • 1
  • 16
  • 26