t_machine Posted September 19, 2007 Share Posted September 19, 2007 Hi, I am wondering if anyone can help with this problem. I would like to get only the first key and value from my array. Example $myarray = array('linkname1'=>'linkurl', 'linkname2'=>'linkurl2', 'linkname3'=>'linkurl3'); What I would like is to get only the first "linkname1" and "linkurl" It will be use in my codes -> <a href="linkurl">linkname1</a> Thanks for any help Link to comment https://forums.phpfreaks.com/topic/69918-solved-how-to-get-first-key-and-value-from-array/ Share on other sites More sharing options...
BlueSkyIS Posted September 19, 2007 Share Posted September 19, 2007 $keys = array_keys($myarray); $key1 = $keys[0]; $value1 = $myarray[$key1]; Link to comment https://forums.phpfreaks.com/topic/69918-solved-how-to-get-first-key-and-value-from-array/#findComment-351163 Share on other sites More sharing options...
t_machine Posted September 19, 2007 Author Share Posted September 19, 2007 Thank you very much It works perfectly Link to comment https://forums.phpfreaks.com/topic/69918-solved-how-to-get-first-key-and-value-from-array/#findComment-351173 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.