How to use a variable to identify an array key

I am trying to search an array for a key value that I don’t know until runtime. So I want to build the key value as a variable and then search the array to see if that key exists, as follows:

$arrkey = $this->content[4][$i]['gridrowid'] . "-" . $this->content[5][$z]['gridcolumnid'];
if (array_key_exists ($this->content[6] , $arrkey)) {

In this example $arrkey is a string “1-1” and the array $this->content[6] looks like:

    [6]=>
  array(1) {
    ["1-1"]=>
    string(1) "2"

But it is not finding the key. Or at least it is not entering the “if” statement. Thanks

Don’t you have the arguments reversed ?

bool array_key_exists ( mixed $key , array $array )

Sure do. Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.