note 36587 modified in function.array-rand by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:48:38 +0000 |
| Subject: | note 36587 modified in function.array-rand by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79833@lists.php.net to get a copy of this message | ||
The function go well ever that you work with a simple array. An array of arrays (also called a
table), not works with the function correctly. Example:
<?php
$a=array(array(0,1),array(1,2),array(2,3),array(3,4),array(4,5));
echo $a[0][0];echo"<br>";
echo $a[1][0];echo"<br>";
$b=array_rand($a,2);
echo $b[0][0];echo"<br>"; //This writes nothing
echo $b[1][0];echo"<br>"; //This writes nothing
?>
If you are in this situation, you will need to make your own solution.
--was--
The function go well ever that you work with a simple array. An array of arrays (also called a
table), not works with the function correctly. Example:
$a=array(array(0,1),array(1,2),array(2,3),array(3,4),array(4,5));
echo $a[0][0];echo"<br>";
echo $a[1][0];echo"<br>";
$b=array_rand($a,2);
echo $b[0][0];echo"<br>"; //This writes nothing
echo $b[1][0];echo"<br>"; //This writes nothing
If you are in this situation, you will need to make your own solution.
http://php.net/manual/en/function.array-rand.php