Convert a GET variable containing a range of numbers to a string in PHP

advertisements

I have a get variable in this format : 0-1499. Now I need to convert it to a string so that I can explode the variable. For this I tried to convert it to string , but I am not getting any output. Here is the sample code :

$mystring = $_GET['myvars']; //equals to 0-1499;
//$mystring = (string)$mystring;
$mystring = strval($mystring);
$mystring = explode("-",$mystring);
print_r($mystring);

The above print_r() shows an array Array ( [0] => [1] => 1499 ). That means it calculates the $mystring before converted into string. How can I send 0-1499 as whole string to explode ?


I have a get variable in this format : 0-1499

When you grab this variable from the URL say.. http://someurl.com/id=0-1499

$var = $_GET['id'];

This will be eventually converted to a string and you don't need to worry about it.

Illustration

FYI : The above illustration used the code which you provided in the question. I didn't code anything extra.