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,471
  • 17
  • 87
  • 173
satya
  • 3,380
  • 7
  • 42
  • 119

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,488
  • 1
  • 15
  • 26