Jump to content

[SOLVED] Warning: key(): Passed variable is not array


Recommended Posts

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.

 

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

  • 2 weeks later...
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.