lundi 10 avril 2023

Random item from PHP array = "access array offset"

Im trying to get a single random key => value from an array but im getting the following error. Any ideas what im doing wrong?

$colors = array("Yellow Sun" => "FAE500", "Golden" => "fab600", "Orange Juice" => "FF6D00", "Photo Blue" => "A2E5F4");


$shuffled = shuffle($colors);
print_r($shuffled[0]);

"Warning: Trying to access array offset on value of type bool in"




Aucun commentaire:

Enregistrer un commentaire