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
https://forums.phpfreaks.com/topic/172323-solved-print-array-key/
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.

 

 

 

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()

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.