drseuss Posted June 12, 2010 Share Posted June 12, 2010 Hello everyone, i'm playing with the PHP GD library, just to keep myself practicing. In the code I am grabbing the coords from a DB and putting them in an array. The code works, but I don't think its the best way of doing it... it just doesn't look right. I'm not really used to making arrays out of loops, but this is my code; $place = 0; $pixelQ = $class->query("select * from pixelCoords where owner='1'"); while($pixelF = $class->fetch()) { $corners[$place+1] = array('x' => $pixelF['x'], 'y' => $pixelF['y']); $place++; } This is a small part of the script, of me calling the array to be used; imagesetpixel($gd, round($x),round($y), $red); $a = rand(1, $place); $x = ($x + $corners[$a]['x']) / 2; $y = ($y + $corners[$a]['y']) / 2; Link to comment https://forums.phpfreaks.com/topic/204592-pixel-control-with-arrays/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.