Jump to content

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


phpdolan

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...

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.