I\'m fairly new to PHP - programming in general. So basically what I need to accomplish is, create an array of x amount of numbers (created randomly) whose value add up
I'm not sure whether I understood you correctly, but try this:
$n = 4; $max = 30; $array = array(); do { $random = mt_rand(0, $max); if (!in_array($random, $array)) { $array[] = $random; $n--; } } while (n > 0);