I'm having a problem when using array_rand.
The thing is that I called some values from my database into an array, and then I did array_rand to randomly select one of those values (you don't say).
$query = mysqli_query($con,"SELECT * FROM random");
while ($row = mysqli_fetch_assoc($query)) {
$num[] = $row["id"];
}
If I do a print_r($num);, I get the following:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
[10] => 11
[11] => 12
[12] => 13
[13] => 14
)
But when doing array_rand($num);, one of the values that I randomly get is 0, which as you can see, is not in the list, therefore the rest of the code that uses this random value won't work if it cames up with it.
I searched in Google for this problem, but couldn't find a solution, I'm sorry if this has been mentioned before.
Hopefully you can help me fix this problem.
Thanks in advance.