2
$img = array
(
array("1.jpg","Logo","Tigre"),
array("2.jpg","Logo","Cão"),
array("3.jpg","Logo","Montanha"),
array("4.jpg","banner","Design Grafico"),
array("5.jpg","Logo","Dentista"),
array("6.jpg","Logo","Basketball")
);
I wanted the array to look like this
$img = array
(
array("5.jpg","Logo","Dentista"),
array("1.jpg","Logo","Tigre"),
array("4.jpg","banner","Design Grafico"),
array("3.jpg","Logo","Montanha"),
array("2.jpg","Logo","Cão"),
array("6.jpg","Logo","Basketball")
);
I tried this:
function shuffle_assoc($list) {
if (!is_array($list)) return $list;
$keys = array_keys($list);
shuffle($keys);
$random = array();
foreach ($keys as $key) {
$random[$key] = $list[$key];
}
return $random;
}
$img = array
(
array("1.jpg","Logo","Tigre"),
array("2.jpg","Logo","Cão"),
array("3.jpg","Logo","Montanha"),
array("4.jpg","banner","Design Grafico"),
array("5.jpg","Logo","Dentista"),
array("6.jpg","Logo","Basketball")
);
$img = shuffle_assoc($img);
print_r($img);
Thanks for the -1 but I still need xD help
– Amadeu Antunes
$imagens[] = shuffle($img[0])
doesn’t do what you need?– Ricardo Moraleida
is not working
– Amadeu Antunes
I wanted to shuffle the position of the arrays but keeping the order of each "line"
– Amadeu Antunes