PHP Illegal String Offset Warning on Array
14,035
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
Comments
-
Willze Fortner almost 2 years
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.