Jump to content

[SOLVED] Print Array Key?


JMair

Recommended Posts

I'm not even sure i have the name correct, but I think it's called the array key.

 

$array[1]

 

I'm referring to the 1. (Array key?)

 

Anyhow. I have an array with each key named, and a variable assigned to each key of course. .

I would like to print just the array key in an echo line and I'm not sure where to look.

Link to comment
Share on other sites

That is great! However I need to return on Key and not all. I've been tinkering around with it but can't seam to get it to echo 1 key.

 

$todo = array( 
"9AM" => "Wake Up.",
"10AM" => "Drink make hot tea.",
"11AM" => "Finish reading CNET news.",
);

 

So if I wanted to just echo a the Key value to Wake Up. I'm not sure how to do it.

 

 

 

Link to comment
Share on other sites

That is great! However I need to return on Key and not all. I've been tinkering around with it but can't seam to get it to echo 1 key.

 

$todo = array( 
"9AM" => "Wake Up.",
"10AM" => "Drink make hot tea.",
"11AM" => "Finish reading CNET news.",
);

 

So if I wanted to just echo a the Key value to Wake Up. I'm not sure how to do it.

edit: nvm, use array_search()

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.