Nikita 웃
Nikita 웃

Reputation: 2060

Convert URL GET var to another variable

I have a URL variable that looks like this:

http://myURL?price_rang=2%5E%5E99_5%5E%5E99

With php echo on the price_rang GET var it translates to 25E5E99_55E5E99 .

I need it to be converted to 2.99_5.99 and then explode it and use the first and second part in a query.

What would be the best way to convert this string and explode it (or just convert it)?

Upvotes: 1

Views: 98

Answers (2)

CodeGodie
CodeGodie

Reputation: 12132

Take it step by step.

  1. get the info
  2. replace your string
  3. explode

Try the following:

$range = $_GET['price_rang'];
$range = str_replace("^^", ".", $range);
$val = explode("_", $range);
var_dump($val);

Upvotes: 1

Deep
Deep

Reputation: 2512

You need rawurldecode() or urldecode() function

$val = explode('_', rawurldecode($_GET['price_rang']));

Upvotes: 0

Related Questions