Reputation: 146302
How do i get rid of this error?
code:
function get_green_entities($c,$array){
$thisC = &$this->output[$this->sessID];
$timeDif = 4;
$cols = count($thisC['clientCols'])+1;
if(!isset($array['Entity ID'])){
return get_grey($c);
}
if(!isset($thisC['CURRTIME'][$array['Entity ID']])){
$thisC['CURRTIME'][$array['Entity ID']] =
(isset($array['timestamp'])?$array['timestamp']:null);
}
}
I am hitting that error in that last if statement's line:
$thisC['CURRTIME'][$array['Entity ID']] =
(isset($array['timestamp'])?$array['timestamp']:null);
And i know that $array['Entity ID']=4
How do i fix this?
Thanks :-)
UPDATE 3
I removed the dumps as they are a bit sensitive
Upvotes: 0
Views: 735
Reputation: 48284
There's only three possibilities either $thisC
, $thisC['CURRTIME']
, or $array
is not an array...
You can alter the function signature to protect against the latter:
function get_green_entities($c, array $array)
If $array
is the problem, it will get triggered when calling the function. So now if the problem persists, you know it has something to do with $thisC
.
Calling var_dump
on the line before the error should make it obvious what the problem is.
Consider the behavior of:
$array = 'test';
if (!isset($array['foo']['bar']))
$array['foo']['bar'] = true; // error is triggered here
So I would think the problem is that $thisC['CURRTIME']
is not always an array like you expect.
Upvotes: 1