Here is a piece of PHP code:
public function getAllianceRank ($ id) {
$ this- & gt; procARankArray ();
while (1) {
if (count ($ this- & gt; rankarray) & gt; 1) {
$ key = key ($ this- & gt; rankarray);
if ($ this- & gt; rankarray [$ key] ["id"] == $ id) {// THIS LINE HAS A WARNING
return $ key;
break;
} else {
if (! next ($ this- & gt; rankarray)) {
return false;
break;
}
}
} else {
return 1;
}
}
}
And here is the warning itself:
Warning: Illegal string offset 'id' in /var/www/GameEngine/Ranking.php on line 189
As I understand it, there should be an array, and there should be a string, right? How do I fix this warning?
Answer 1, authority 100%
if (is_array ($ this- & gt; rankarray [$ key]) & amp; & amp; $ this- & gt; rankarray [$ key] ["id"] == $ id)