Jump to content

array_rand()


Jaswinder

Recommended Posts

as we know array_rand outputs the keys,, how to get value from it of the random element

 

i tried this:-

 

<?php

$n = array("lions", "tigers", "bears", "kittens");

 

var_dump(array_rand($n));

 

?>

and also how to get values, if  i pass the 2nd parameter i.e. number of random keys we need,, because the array returned by it contain keys as their values

Link to comment
https://forums.phpfreaks.com/topic/281029-array_rand/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.