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;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.