Jump to content

[SOLVED] Having a bit of trouble with this,


jscix

Recommended Posts

Basically what this does is retrive the $_get variable 'list', then if it's empty assign it an array of 0, 10 as default, otherwise grab the values on either side of the - delimiter.

 

The problem is, when the default numbers are processed and I print the array I get:

Array ( [0] => 0 [1] => 10 )

 

This works and it prints out 0 and 10. However.. when I specify the numbers, using  "blah.php?list=0-10"

I get the exact same array:

 

Array ( [0] => 0 [1] => 10 )

 

However it is not printing out the numbers... It prints a null value... what is happening? anyone?

 


$limitres = ($_GET['list']);
if (!isset($limitres)) { $dirty2 = Array(0, 10); }
else {
$dirty  = strip_tags($limitres);
$dirty2 = explode("-", $dirty);
}

if (is_array($dirty2)) {
$numof = count($dirty2);
if ($numof != "2") { die("Invalid page limiter"); }
$pone = $dirty2[0];
$ptwo = $dirty2[1];
if (is_int($pone) && is_int($ptwo)) {
$clean1 = ($pone);
$clean2 = ($ptwo);
}
if ($clean1 > clean2) { die("Page limiter format must be lesser number-greater number."); }
} 

print $clean1 . "<br>";
print $clean2 . "<br>";

Link to comment
https://forums.phpfreaks.com/topic/42396-solved-having-a-bit-of-trouble-with-this/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.