Function that makes $ foo [array_rand ($ foo)] direct

-2

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?

    
asked by anonymous 01.10.2015 / 19:55

1 answer

3

Short answer: No.

There is no native function to return a random array value according to array list in> .

    
01.10.2015 / 20:39