Reputation: 141
I get illegal string offset warning from the array inside if statement
411. if (is_array($attrib['affixes'])) { // merge
412. $new_affix = array_merge($attrib['affixes'], $new_affix);
413. }
Exactly the warning is
"Warning: Illegal string offset 'affixes' in C:\xampp\htdocs\pengakar-master\src\Pengakar.php on line 411"
I insert the full code below :
Another part is alright. Only that part that get the error
Thanks for the help.
Upvotes: 3
Views: 14776
Reputation: 376
The illegal offset means that the index your are referencing does not exist. So, in this case the 'affixes' index of the array is never defined. To prevent the error, change the code as follows:
if (isset($attrib['affixes']) && is_array($attrib['affixes'])) { // merge
$new_affix = array_merge($attrib['affixes'], $new_affix);
}
Look over here for more information about the error: Illegal string offset Warning PHP
Upvotes: 5