php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3281 Array handling returns "Array" or does something stupid when keys are strings
Submitted: 2000-01-22 13:47 UTC Modified: 2000-01-22 21:49 UTC
From: johnston at itactics dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Latest CVS (22/01/2000) OS: Linux
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: johnston at itactics dot com
New email:
PHP Version: OS:

 

 [2000-01-22 13:47 UTC] johnston at itactics dot com
<?php
        $a[b]['a c'] = "lala";
        echo "$a[b]['a c']";
?>

returns "Array"

<?php
        $z['hello baby'] = "yo";
        $z['bubye baby'] = "bah";
        array_keys($z);
?>

doesnt even return anything.

I'm trying to write a script that parses out a mail header into $message[header][headername] = "value";
and headername might be a few words or might have some weird chars in it and php's buggy arrays are causing me grief - lots of grief.  It wouldnt even matter if i removed all weird characters.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-01-22 21:02 UTC] johnston at itactics dot com
<?php
	$[b]['a c'] = "lala";
              echo "$a[b]['a c']";
?>

returns "Array"

<?php
	$z['hello baby'] = "yo";
	$z['bubye baby'] = "bah";
	print array_keys($z);
?>

also, returns "Array"

I'm trying to write a script that parses out a mail header into $message[header][headername] = "value"; and headername might be a few words or might have some weird chars in it and php's buggy arrays are causing me grief - lots of grief.  It wouldnt even matter if i removed all weird characters.
 [2000-01-22 21:49 UTC] torben at cvs dot php dot net
These are not bugs; both behaviours are explained in the manual. They
result from PHP not being able to simply echo or print an array; if you
try it, PHP prints out 'Array' to let you know that you've tried to do that.

The first issue is related to the problem of interpreting array syntax
inside encapsulating strings; this and the above are discussed at:

   http://www.php.net/manual/language.types.array.php3

The second issue stems from the fact that array_keys() returns the keys
as an array, which again cannot simply be echoed out:

   http://www.php.net/manual/function.array-keys.php3
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 11:01:32 2024 UTC