php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24494 incorrect value for texte in array
Submitted: 2003-07-04 08:08 UTC Modified: 2003-07-04 10:14 UTC
From: bibifoc23 at yahoo dot fr Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.2 OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bibifoc23 at yahoo dot fr
New email:
PHP Version: OS:

 

 [2003-07-04 08:08 UTC] bibifoc23 at yahoo dot fr
Description:
------------
hello,

I get strange behaviour with array:

<?php

$array = array ( 'TM' => 'test', 'autre dossier' => 'texte' ) ;

print_r ( $array );

echo $array['TM']['TM']."\n";
?>

the echo command return the first character of string. But $array['TM'] is not an array, so i expext to have an error wen i call $array['TM']['TM']. 
But PHP convert the second index to 0. 

Thanks

Reproduce code:
---------------
<?php

$array = array ( 'TM' => 'test', 'autre dossier' => 'texte' ) ;

print_r ( $array );

echo $array['TM']['TM']."\n";
?>


Expected result:
----------------
return error or warning.

Actual result:
--------------
return the first character of the string

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-04 10:14 UTC] jay@php.net
This is expected behaviour, I believe. $array['TM'] is not 
an array, it's a string, but strings can be treated like 
arrays. So 'TM' gets converted to 0 given PHP's type 
juggling rules, and $array['TM'][0] is 't', so it's 
working as expected. 
 
J 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 16:01:36 2025 UTC