|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-11-18 22:06 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
Description: ------------ When using PHP to build a multi-dimensional array, the first 5 days, this code worked fine. Suddenly, PHP got picky, and decided it shouldn't work anymore. # Because i declare $myp to become empty, (because this $myp is put into a loop), I want the array to be empty next time around. So I declared it $myp='' before it starts. This worked fine for a few days, I have been testing this inside and out. All of a sudden FOR NO REASON, it just starts telling me this error. ''Cannot use string offset as an array site'' Hmm? Well I did manage to fix it, by declaring $myp[0][0]='' instead of $myp='', however it seems like a really weird bug, because it decided to jump at me 5 days after usage. Code examples below. Maybe you guys should look into it. Reproduce code: --------------- <? $myp=''; $myp=BuildAMultiArray(0,0,"test"); $GTIN = $myp[0][0]; echo $GTIN; function BuildAMultiArray($l1, $l2, $str) { $built[$l1][$l2] = $str; return $built; } ?> Expected result: ---------------- test Actual result: -------------- CODE THAT FIXED IT: <? $myp[0][0]=''; $myp=BuildAMultiArray(0,0,"test"); $GTIN = $myp[0][0]; function BuildAMultiArray($l1, $l2, $str) { $built[$l1][$l2] = $str; return $built; } ?>