ID: 40354 User updated by: andreyra at chtivo dot ru Reported By: andreyra at chtivo dot ru Status: Bogus Bug Type: Arrays related Operating System: Windows 2003 Server PHP Version: 5.2.0 New Comment:
I'm sorry that's my fault. Previous Comments: ------------------------------------------------------------------------ [2007-02-05 18:40:30] [EMAIL PROTECTED] See the difference between: array("name"=>"value") and array("\'name\'"=>"value") ------------------------------------------------------------------------ [2007-02-05 18:34:03] andreyra at chtivo dot ru The strange behaviour consists in the fact of discrepancy between results of print_r() procedure and a real condition of a variable. In my sample print_r($arr) say: Array ( ['name'] => Some text ) But in the next string, then I try to read $arr['name'] - PHP sayd "PHP Notice: Undefined index: name in test.php..." Imho there is no difference - bogus my bug or not, the most important that I have got used to trust that results of print_r() procedure are used for debugging and always give out unequivocal result. On this example I have received a full refutation of my vision. ------------------------------------------------------------------------ [2007-02-05 09:25:44] [EMAIL PROTECTED] 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. ------------------------------------------------------------------------ [2007-02-04 17:10:30] andreyra at chtivo dot ru Description: ------------ I have found strange behaviour with PHP POST/GET arrays. With print_r() command I have see all contents of array, but if I trying to access to values of array directly - I have got errors. I have test this code with: php5.1.2 php5.2.0 php5.2-win32-200702041530 Apache2.0.58/win32/php5apache2.dll Apache2.2.3/win32/php5apache2_2.dll Apache2.2.4/win32/php5apache2_2.dll And always I have same results. In my php.ini: register_globals = On register_long_arrays = On register_argc_argv = On post_max_size = 512M Reproduce code: --------------- <form name="topics" method="post"> <input type="text" name="topic[1]['name']" value="Some text"><br/> <button onclick="this.form.submit(true);">POST</button> </form> <?php if (!isset($_POST['topic'])){ return false; }; if (!is_array($_POST['topic'])){ return false; }; foreach ($_POST['topic'] as $topic_id=>$arr){ print_r($arr); if (!isset($arr['name'])){ echo "<br/>\r\nERROR! NAME field is not set!\r\n"; continue; }; echo 'OK.'; }; ?> Expected result: ---------------- OK. Actual result: -------------- ERROR! NAME field is not set! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40354&edit=1