phpdolan Posted January 24, 2008 Share Posted January 24, 2008 Any suggestions on how the following should be coded? The desire is to return the number of the first key in the array. Here's what I've got, which results in the Subject Warning. The code: reset($hi1_array[$j_date]); $first = key($hi1_array[$j_date]); The multidimensional array (one key): It typically has 40 keys. [1]=> array(6) { ["off_duty"]=> string(2) "DO" ["date"]=> string(1) "1" ["jdate"]=> string(1) "1" ["day"]=> string(3) "Tue" ["min_307"]=> float(0) [307]=> string(4) "8:21" Thanks for any replies. Quote Link to comment https://forums.phpfreaks.com/topic/87484-solved-warning-key-passed-variable-is-not-array/ Share on other sites More sharing options...
cooldude832 Posted January 24, 2008 Share Posted January 24, 2008 have you tried writting your arrays like <?php $data = array(); $data['1']['Name'] = "joe"; $data['1']['Age'] = "27"; $data['2']['Name'] = "george"; $data['2']['Age'] = "32"; ?> A lot easier to read as I can not follow what you threw out without tabs Quote Link to comment https://forums.phpfreaks.com/topic/87484-solved-warning-key-passed-variable-is-not-array/#findComment-447459 Share on other sites More sharing options...
teng84 Posted January 24, 2008 Share Posted January 24, 2008 try $first = key($hi1_array); because it says its not an array maybe your $hi1_array[$j_date] is no longer an array(multidimensional).. Quote Link to comment https://forums.phpfreaks.com/topic/87484-solved-warning-key-passed-variable-is-not-array/#findComment-447469 Share on other sites More sharing options...
phpdolan Posted January 25, 2008 Author Share Posted January 25, 2008 Thanks cooldude832 and teng82, For some reason the syntax I tried first --> $first = key($hi1_array) , is working now. That is the returning the correct first key after the array is reset. Quote Link to comment https://forums.phpfreaks.com/topic/87484-solved-warning-key-passed-variable-is-not-array/#findComment-448433 Share on other sites More sharing options...
teng84 Posted January 25, 2008 Share Posted January 25, 2008 who's teng82? your making me old that makes me 2 yrs older! Quote Link to comment https://forums.phpfreaks.com/topic/87484-solved-warning-key-passed-variable-is-not-array/#findComment-448440 Share on other sites More sharing options...
phpdolan Posted February 6, 2008 Author Share Posted February 6, 2008 who's teng82? your making me old that makes me 2 yrs older! I thought that'd make you 2 years younger... You're kinda old to be programming??? Quote Link to comment https://forums.phpfreaks.com/topic/87484-solved-warning-key-passed-variable-is-not-array/#findComment-460263 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.