Hello, first time here... Apologize if I am out of protocol.
The following is, well, working, but failing:
<?php
$random = array(
"test",
"pass",
"fail",
"works",
"nope",
"another",
"shortaug",
"stuck",
"dumb"
);
$current = "test";
$r1 = $random[$_GET['r1']];
$r2 = $random[$_GET['r2']];
function array_filter($array, $filter){
$newArray = array ();
foreach($array as $object)
if(stristr($object, $filter)===false && strlen($object)>0)
$newArray[] = $object;
return $newArray;
}
$random = array_delete($random, $current);
$random = array_delete($random, $r1);
$random = array_delete($random, $r2);
$rand = array_rand($random, 2);
$r1 = $random[$rand[0]];
$r2 = $random[$rand[1]];
?>
Now, a print_r($random) will show that the array has indeed been filtered and the index keys adjusted accordingly.
The problem is with $rand = array_rand($random,2);. It is acting as if the original array has not been filtered and regenerated.
IE: If $_GET['r1'] is equal to 'pass', then in theory it should not ever show up in either $r1 or $r2 once I run array_rand, but it is. The same for any value set as $r2. Now, the way I am using the script, I cannot tell if it is behaving in the same manner for $current, but I see no reason why it wouldn't be failing in that one too.
Any help?