Is there a native PHP function that does this without having to use array_rand
in the array key?
While working fine and being a simple slice, here is a simplified example of the doubt:
//Declarando um Array com um Array dentro
$array_pai = Array (
[0] => Array (
[bar] => ":)"
[altbar] => "=]"
)
[1] => Array (
[bar] => ":("
[altbar] => "=["
)
[2] => Array (
[bar] => ":p"
[altbar] => "=p"
)
);
//Pegando o Array filho aleatorio
$array_filho= $array_pai[array_rand($array_pai)];
print_r($array_filho);
Result:
Array (
[bar] => ":)"
[altbar] => "=]"
)
Is there a native function that does this?