<?php
echo "<form method='post' action='".$HTTP_SERVER_VARS['PHP_SELF']."'>";
echo "no of notes: ";
echo "<input type='text' name='br' size='1'> ";
echo "<input class='input' type='submit'></form>";
echo "<p>";
if ($_POST['br'] != "") {
$items = array(
1 => array(
'src' => 'c',
),
2 => array(
'src' => 'c#',
),
3 => array(
'src' => 'd',
),
4 => array(
'src' => 'd#',
),
5 => array(
'src' => 'e',
),
6 => array(
'src' => 'f',
),
7 => array(
'src' => 'f#',
),
8 => array(
'src' => 'g',
),
9 => array(
'src' => 'g#',
),
10 => array(
'src' => 'a',
),
11 => array(
'src' => 'a#',
),
12 => array(
'src' => 'b',
),
13 => array(
'src' => 'c2',
)
);
$numberOfItems = $_POST['br'];
$randItems = array_rand($items, $numberOfItems);
for ($i = 0; $i < $numberOfItems; $i++) {
$item = $items[$randItems[$i]];
echo $item['src']." | ";
}
}
?>
so, this is my ultrasimple script that outputs various numbers of notes, depending on user input. of course, if someone put 14 or more in input field i got the following error:
Warning: array_rand() [function.array-rand]: Second argument has to be between 1 and the number of elements in the array.....
so the question is: what to change so users can input for example number 999 and the script would output 999 random notes from array?
thank you in advance
and...