So I'm having a tough time with this one. I almost had it down, but something went wrong, and I'm not sure what it was.
Anyway, I want to take two arrays, one known and one required and compare them to see if the requirements are met.
Have something like:
$knownarray = ("1:5","2:3","7:4","32:1");
and require
$requirearray = ("17:2","2:2","1:3");
$requirearray2 = ("7:2","1:4");
Now what I need to do is take my requirements and seperate them, and compare to the known array. Then if all conditions are met, I want it to return an id for it, for later use. So with the above requirements, the numbers are seperated by the colon for the requiring id as well as the requiring number. The first example I want to be able to discard since the 17:2 is not found or met in the known, while the others are both found, and both with lower requiring numbers than whats known. The second would go through since all requirements are met. Heres what I currently have:
Any suggestions?
Anyway, I want to take two arrays, one known and one required and compare them to see if the requirements are met.
Have something like:
$knownarray = ("1:5","2:3","7:4","32:1");
and require
$requirearray = ("17:2","2:2","1:3");
$requirearray2 = ("7:2","1:4");
Now what I need to do is take my requirements and seperate them, and compare to the known array. Then if all conditions are met, I want it to return an id for it, for later use. So with the above requirements, the numbers are seperated by the colon for the requiring id as well as the requiring number. The first example I want to be able to discard since the 17:2 is not found or met in the known, while the others are both found, and both with lower requiring numbers than whats known. The second would go through since all requirements are met. Heres what I currently have:
PHP Code:
$getall = $DB_site->query("SELECT * FROM $table");
while($listall = $DB_site->fetch_array($getall)){
if (!$listall[requirement]){
$genids .= "$listall[id], ";
}else{
$requirearray = explode(", ", $listall[requirement]);
for($i=0; $i<count($requirearray); $i++){
$rqd = explode(":", $requirearray[$i]);
}
$knownarray = explode(", ",$knownarray);
for($j=0; $j<count($knownarray); $j++){
$hve = explode(":", $val);
if ($hve[0] == $rqd["0"]){
if (strcmp($hve[1],$rqd[1])>='0'){
$genids .= "$getjobs[id], ";
}
}
}
}
}
$genids = substr($genids,0,strlen($genids)-2);
return $genids;
Comment