[PHP-DEV] Bug #14092 Updated: Associative array,value in array can not be zero
ID: 14092 Updated by: derick Reported By: [EMAIL PROTECTED] Old Status: Open Status: Closed Bug Type: Arrays related Operating System: linux RH7.0 PHP Version: 4.0.6 New Comment: THis is expected behavior, if current($pole) evaluates to 0, it's considered false as a while conditition: while (current($pole)) { --- while (0) { You want to use: while (current($pole) !== FALSE) { Previous Comments: [2001-11-17 06:28:33] [EMAIL PROTECTED] Associative arrays seems to be broken in some way. it is impossible to use something like $variable[something]=0; example scripts: A: ? $userdata[user_star]='10'; $userdata[user_pohlavi]=U; $userdata[user_count]=1; $userdata[user_vip]=N; $userdata[user_lang]=CZ; $userdata[user_tld]=CZ; $userdata[user_fags]=A; show_values($userdata); function show_values($pole) { echo show; reset($pole); while(current($pole)) { echo index: .key($pole). value: .current($pole).br; next($pole); } } ? Following script show proper results: showindex: user_star value: 10 index: user_pohlavi value: U index: user_count value: 1 index: user_vip value: N index: user_lang value: CZ index: user_tld value: CZ index: user_fags value: A But Script B: ? $userdata[user_star]='10'; $userdata[user_pohlavi]=U; $userdata[user_count]=0; $userdata[user_vip]=N; $userdata[user_lang]=CZ; $userdata[user_tld]=CZ; $userdata[user_fags]=A; show_values($userdata); function show_values($pole) { echo show; reset($pole); while(current($pole)) { echo index: .key($pole). value: .current($pole).br; next($pole); } } ? (only thig I change is : $userdata[user_count]=0; ) give INCORRECT result showindex: user_star value: 10 index: user_pohlavi value: U ..and rest of the array gone. PHP manual say that A 'key' is either a nonnegative integer or a string... ..A 'value' can be anything. , so I thing I found bug... My system: RedHat7.0cz , kernel 2.4.10+LIDS 1.0.16,output of PhpInfo() function : PHP Version 4.0.6 System Linux porky.devel.redhat.com 2.4.5-7smp #1 SMP Tue Jun 26 14:19:49 EDT 2001 i686 unknown Build Date Aug 27 2001 Configure Command './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs' '--with-bz2' '--with-curl' '--with-db3' '--with-dom' '--with-exec-dir=/usr/bin' '--with-gd' '--with-gdbm' '--with-gettext' '--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png' '--with-regex=system' '--with-ttf' '--with-zlib' '--with-layout=GNU' '--enable-debugger' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-yp' '--enable-wddx' '--without-mysql' '--without-unixODBC' '--without-oracle' '--without-oci8' '--with-pspell' '--with-xml' Server API Apache Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php.ini ZEND_DEBUG disabled Thread Safety disabled This program makes use of the Zend scripting language engine: Zend Engine v1.0.6, Copyright (c) 1998-2001 Zend Technologies PHP 4.0 Credits Configuration PHP Core Directive Local Value Master Value allow_call_time_pass_reference On On allow_url_fopen 1 1 arg_separator.input arg_separator.output asp_tags Off Off auto_append_file no value no value auto_prepend_file no value no value browscap no value no value default_charset no value no value default_mimetype text/html text/html define_syslog_variables Off Off disable_functions no value no value display_errors On On display_startup_errors On On doc_root no value no value enable_dl On On error_append_string /font/h3 /font/h3 error_log no value no value error_prepend_string h3font color=ff h3font color=ff error_reporting 2039 2039 expose_php On On extension_dir
[PHP-DEV] Bug #14092 Updated: Associative array,value in array can not be zero
ID: 14092 Updated by: hholzgra Reported By: [EMAIL PROTECTED] Old Status: Closed Status: Bogus Bug Type: Arrays related Operating System: linux RH7.0 PHP Version: 4.0.6 New Comment: or even better: use each() or foreach() to traverse arrays http://php.net/each http://php.net/foreach Previous Comments: [2001-11-17 06:32:02] [EMAIL PROTECTED] THis is expected behavior, if current($pole) evaluates to 0, it's considered false as a while conditition: while (current($pole)) { --- while (0) { You want to use: while (current($pole) !== FALSE) { [2001-11-17 06:28:33] [EMAIL PROTECTED] Associative arrays seems to be broken in some way. it is impossible to use something like $variable[something]=0; example scripts: A: ? $userdata[user_star]='10'; $userdata[user_pohlavi]=U; $userdata[user_count]=1; $userdata[user_vip]=N; $userdata[user_lang]=CZ; $userdata[user_tld]=CZ; $userdata[user_fags]=A; show_values($userdata); function show_values($pole) { echo show; reset($pole); while(current($pole)) { echo index: .key($pole). value: .current($pole).br; next($pole); } } ? Following script show proper results: showindex: user_star value: 10 index: user_pohlavi value: U index: user_count value: 1 index: user_vip value: N index: user_lang value: CZ index: user_tld value: CZ index: user_fags value: A But Script B: ? $userdata[user_star]='10'; $userdata[user_pohlavi]=U; $userdata[user_count]=0; $userdata[user_vip]=N; $userdata[user_lang]=CZ; $userdata[user_tld]=CZ; $userdata[user_fags]=A; show_values($userdata); function show_values($pole) { echo show; reset($pole); while(current($pole)) { echo index: .key($pole). value: .current($pole).br; next($pole); } } ? (only thig I change is : $userdata[user_count]=0; ) give INCORRECT result showindex: user_star value: 10 index: user_pohlavi value: U ..and rest of the array gone. PHP manual say that A 'key' is either a nonnegative integer or a string... ..A 'value' can be anything. , so I thing I found bug... My system: RedHat7.0cz , kernel 2.4.10+LIDS 1.0.16,output of PhpInfo() function : PHP Version 4.0.6 System Linux porky.devel.redhat.com 2.4.5-7smp #1 SMP Tue Jun 26 14:19:49 EDT 2001 i686 unknown Build Date Aug 27 2001 Configure Command './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs' '--with-bz2' '--with-curl' '--with-db3' '--with-dom' '--with-exec-dir=/usr/bin' '--with-gd' '--with-gdbm' '--with-gettext' '--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png' '--with-regex=system' '--with-ttf' '--with-zlib' '--with-layout=GNU' '--enable-debugger' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-yp' '--enable-wddx' '--without-mysql' '--without-unixODBC' '--without-oracle' '--without-oci8' '--with-pspell' '--with-xml' Server API Apache Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php.ini ZEND_DEBUG disabled Thread Safety disabled This program makes use of the Zend scripting language engine: Zend Engine v1.0.6, Copyright (c) 1998-2001 Zend Technologies PHP 4.0 Credits Configuration PHP Core Directive Local Value Master Value allow_call_time_pass_reference On On allow_url_fopen 1 1 arg_separator.input arg_separator.output asp_tags Off Off auto_append_file no value no value auto_prepend_file no value no value browscap no value no value default_charset no value no value default_mimetype text/html text/html define_syslog_variables Off Off disable_functions no value no value display_errors On On display_startup_errors On On doc_root no value no value
[PHP-DEV] Bug #14092 Updated: Associative array,value in array can not be zero
ID: 14092 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Old Status: Bogus Status: Closed Bug Type: Arrays related Operating System: linux RH7.0 PHP Version: 4.0.6 New Comment: I try even to use while (current($pole) != FALSE) with the some (wrong) result. but while (current($pole) !== FALSE) works. Thanx for help and sorry for the mess... Previous Comments: [2001-11-17 06:44:21] [EMAIL PROTECTED] or even better: use each() or foreach() to traverse arrays http://php.net/each http://php.net/foreach [2001-11-17 06:32:02] [EMAIL PROTECTED] THis is expected behavior, if current($pole) evaluates to 0, it's considered false as a while conditition: while (current($pole)) { --- while (0) { You want to use: while (current($pole) !== FALSE) { [2001-11-17 06:28:33] [EMAIL PROTECTED] Associative arrays seems to be broken in some way. it is impossible to use something like $variable[something]=0; example scripts: A: ? $userdata[user_star]='10'; $userdata[user_pohlavi]=U; $userdata[user_count]=1; $userdata[user_vip]=N; $userdata[user_lang]=CZ; $userdata[user_tld]=CZ; $userdata[user_fags]=A; show_values($userdata); function show_values($pole) { echo show; reset($pole); while(current($pole)) { echo index: .key($pole). value: .current($pole).br; next($pole); } } ? Following script show proper results: showindex: user_star value: 10 index: user_pohlavi value: U index: user_count value: 1 index: user_vip value: N index: user_lang value: CZ index: user_tld value: CZ index: user_fags value: A But Script B: ? $userdata[user_star]='10'; $userdata[user_pohlavi]=U; $userdata[user_count]=0; $userdata[user_vip]=N; $userdata[user_lang]=CZ; $userdata[user_tld]=CZ; $userdata[user_fags]=A; show_values($userdata); function show_values($pole) { echo show; reset($pole); while(current($pole)) { echo index: .key($pole). value: .current($pole).br; next($pole); } } ? (only thig I change is : $userdata[user_count]=0; ) give INCORRECT result showindex: user_star value: 10 index: user_pohlavi value: U ..and rest of the array gone. PHP manual say that A 'key' is either a nonnegative integer or a string... ..A 'value' can be anything. , so I thing I found bug... My system: RedHat7.0cz , kernel 2.4.10+LIDS 1.0.16,output of PhpInfo() function : PHP Version 4.0.6 System Linux porky.devel.redhat.com 2.4.5-7smp #1 SMP Tue Jun 26 14:19:49 EDT 2001 i686 unknown Build Date Aug 27 2001 Configure Command './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs' '--with-bz2' '--with-curl' '--with-db3' '--with-dom' '--with-exec-dir=/usr/bin' '--with-gd' '--with-gdbm' '--with-gettext' '--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png' '--with-regex=system' '--with-ttf' '--with-zlib' '--with-layout=GNU' '--enable-debugger' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-yp' '--enable-wddx' '--without-mysql' '--without-unixODBC' '--without-oracle' '--without-oci8' '--with-pspell' '--with-xml' Server API Apache Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php.ini ZEND_DEBUG disabled Thread Safety disabled This program makes use of the Zend scripting language engine: Zend Engine v1.0.6, Copyright (c) 1998-2001 Zend Technologies PHP 4.0 Credits Configuration PHP Core Directive Local Value Master Value allow_call_time_pass_reference On On allow_url_fopen 1 1 arg_separator.input arg_separator.output asp_tags Off Off auto_append_file no value no value