Hi, I need to generate a random array that stores various values. For example,
<form action="testscript.php" method="POST">
Value1:<input type = "text" name="value1">
Value2:<input type = "text" name="value2">
<?php
$valueone = $_POST['value1'];
$valuetwo = $_POST['value2'];
$number = random(1,10); //random value for array
$array[$number] = array($valueone,$valuetwo); //each array number is unique
?>
<input type="submit" name="submit">
</form>
However, I need to make it such that if an array already has values stored in it, it moves on to another random array until it finds an empty one.
Also, since I would need to validate the form, I will require the random array number to remain the same upon submission of the form.
I've tried using a for loop:
for($i=0; $i<1000; $i++){
if(isset($array[$number])){ //if the array is set, since $number is unique, generate new array by randoming another number
$number = random(1,10); //random another value for array
} $i++; }
but it doesn't seem to work the way I want it to.