note 77343 deleted from function.array-rand by bjori
| From: | bjori@php.net | Date: | Sun, 26 Aug 2007 08:25:29 +0000 |
| Subject: | note 77343 deleted from function.array-rand by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-129794@lists.php.net to get a copy of this message | ||
Note Submitter: bharan_n at yahoo dot co dot in
----
I am new to this php. I only edit the codes according to my requirement.I displayed a random list of
words in two sets with 15 in each set.
Below is the code for that.
<?php
srand((float) microtime() * 10000000);
$input = array(
'Art Of Betrayal', 'California Or Bust', 'Flood Gate','Bomb
Shell','Dark Town','Kylies Smiley','song1',
'song50', 'song1', 'song57', 'Dark Town',
'song47', 'song61', 'song56', 'Kylies Smiley',
'song22','song50', 'song1', 'song57', 'Dark Town',
'song47', 'song61', 'song56', 'Kylies
Smiley','song50', 'song1', 'Dark Town', 'song57',
'song54', 'song47', 'song61', 'song56', 'song49',
'Kylies Smiley', 'song53', 'song58');
?>
<table border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%"
id="AutoNumber3">
<tr>
<td width="50%" align="center">SET1</td>
<td width="50%" align="center">SET2</td>
</tr>
<?php
for ($i = 0; $i<sizeof($input);$i++)
{
$rand_keys = array_rand($input,5);
if ($i!=30)
{
?>
<tr>
<td width="50%" align="center">
<?php echo $input[$rand_keys[0]] . "\n <br />" ;?></td>
<td width="50%" align="center">
<?php echo $input[$rand_keys[1]] . "\n <br />" ;?> </td></tr>
<?php
}
else
{?>
</table>
<?php break;
}
}
?>