php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35285 'Cannot use string offset: Multi-Dimensional Array gives error if not init.
Submitted: 2005-11-18 21:53 UTC Modified: 2005-11-18 22:06 UTC
From: admin at sellchain dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.5 OS: Windows Server 2003
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: admin at sellchain dot com
New email:
PHP Version: OS:

 

 [2005-11-18 21:53 UTC] admin at sellchain dot com
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;
}

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-18 22:06 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 20:01:29 2024 UTC