Jump to content

extracting a value from a array using the key


Shadowing

Recommended Posts

Hey guys i have a array i made and im wanting to grab a random value out of the array.

The only way i can see to do this looking at the list of array functions is i need to random a key first?

and then return the value assigned to the random key i just generated?

I only see a function that lets me do the opposite. array_search()

 

so now that i have generated a random key how do I grab just the value from the array using the random key. or is there a function i can just random value?

$explode_names = explode(" ", $planet_names);

$random_key_name = (array_rand($explode_names, 1));


echo $random_key_name;

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.