Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Notice: Uninitialized string offset: 0 [closed]

I'm getting this error in my OpenCart log. Says the error is on line 1 which is:

<?php if(isset($social_discount['name']) && $social_discount['name']!="") { ?>

Would highly appreciate any help to fix this.

like image 788
Chris Judd Avatar asked Feb 18 '23 05:02

Chris Judd


2 Answers

To prevent this error, you should change your code like the following:

<?php if(is_array($social_discount) && isset($social_discount['name']) && $social_discount['name']!="") { ?>
like image 100
ole Avatar answered Feb 27 '23 20:02

ole


$socialdiscount is a string, not an array, so $social_discount['name'] is treated as $social_discount[0] => first character of the string. 0 is not set means $socialdiscount is an empty string.

like image 37
Wrikken Avatar answered Feb 27 '23 19:02

Wrikken