arrays - Get Some Value from Random Function in PHP -
i have 5 value generating random function in php this:
1
0
0
1
1
and code:
for ($i=0; $i<10; $i++){ $n = rand(0, 1); echo $n;echo "<br/ >"}
and now, should value first row , third? value:
1
0
use array store data , access it:
for ($i=0; $i<10; $i++){ $data[] = rand(0, 1); } echo $data[0]; //1st "row" echo '<br>'; echo $data[2]; //3rd "row"
keep in mind php arrays start index 0. learn more php arrays , usage: http://php.net/manual/en/language.types.array.php
Comments
Post a Comment