Post by boopbeepforum » Tue May 18, 2021 11:54 pm

Does foreach() loop need unset($value)?
I don't see the unset in the current or older version of opencart. I've only found one instance of this in a third party mod.
I'm very inexperienced, but when I came across the documentation for foreach(), it says that unset($value) must be used to prevent the next foreach() from referencing the array in the previous foreach().

Newbie

Posts

Joined
Tue May 18, 2021 9:40 pm

Post by straightlight » Thu May 20, 2021 7:43 am

boopbeepforum wrote:
Tue May 18, 2021 11:54 pm
Does foreach() loop need unset($value)?
I don't see the unset in the current or older version of opencart. I've only found one instance of this in a third party mod.
I'm very inexperienced, but when I came across the documentation for foreach(), it says that unset($value) must be used to prevent the next foreach() from referencing the array in the previous foreach().
OC version. However, $var[$key] should be used instead of $value. Since this is about a third party extension you're referring about, contact the extension developer to resolve this issue. $var[$key] is especially useful when unsetting keys from super global variables. The OC core uses these lookups once-in-a-while.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: MajorPain and 79 guests