$count = intval(2147483649) > 0 ? 64 : 32; $rules = range(1,$count); $allows = array_rand($rules, rand(2,$count)); $access = 0; foreach ($allows as $value) { $access |= 1 << array_search($value, $rules); } foreach ($rules as $key => $value) { echo ' [' . $value . ':' . ( ( $access & (1 << $key) ) ? 'Y' : 'N' ). '] '; }