Check boxes into php array

I have a series of check boxes and each has a different rating in them. What I need is to put the variable from the selected check boxes into an array that I can then select a random array entry and then prefrom a query, I have tried to figure it out but I just can’t. Could someone please help me with this or at least point me in the right direction. Sorry I can’t supply any code. I tried to start doing it but then realised that I didn’t really know what I was doing. Which is odd because I can put the selected check boxes into a database but not an array.

Thanks heaps!

Well here is how I was doing it with the database.

<?php for ($i = 0; $i < count($roles); $i++): ?>
  <label for="role<?php echo $i; ?>"><input type="checkbox"
   name="roles[]" id="role<?php echo $i; ?>"
   value="<?php htmlout($roles[$i]['id']); ?>"<?php
   if ($roles[$i]['selected'])
      echo ' checked="checked"';
   ?>/><?php htmlout($roles[$i]['id']); ?></label>:
  <?php htmlout($roles[$i]['role']); ?>
<?php endfor; ?>

I find it hard to believe you can put the values of selected checkboxes into a database but not into an array.

To put the value of anything into an array is simply

$myArray = array();
$myArray[] = some_value;

So after the form submission $_POST[‘roles’] will be your array. Do this to see what it looks like:

echo "<pre>";
echo "</pre>";

To get a random value use [fphp]shuffle[/fphp] or mt_rand(0, count($_POST[‘roles’]));