[thelist] [php] array range check
kris burford
kris at midtempo.net
Thu Oct 2 06:10:03 CDT 2003
hi all,
i've a php recursive function that is generating 2 random numbers (x and y
positions). as each set of new random numbers are created i want to check
(probably through an array) whether those numbers are within a certain
range of previously generated co-ordinates (so that i can prevent overlap
or change colour/size of points where there are multiple occurrences).
i'm having difficulty working out how to check the arrays.
i *think* it could be done like this but i'm not 100% sure that this is the
best way - and as there could be a fair number of points being generated,
it seems like a lengthy process
for ($i=0; $i<count($existingleft); $i++) {
if (($newleft+5 < $existingleft[$i]) && ($newleft-5 > $existingleft[$i]) &&
$newright+5 < $existingright[$i]) && ($newright-5 > $existingright$i])) {
// then get new coordinates
}
}
any guidance would be welcome
tia
kris
More information about the thelist
mailing list