Re: PHP arrays managment bug :-?
| From: | Tomas V.V.Cox | Date: | Fri, 27 Jul 2001 12:53:07 +0000 |
| Subject: | Re: PHP arrays managment bug :-? | ||
| References: | 1 | Groups: | php.dev php.pear.dev |
| Request: | Send a blank email to php-dev+get-61207@lists.php.net to get a copy of this message | ||
Cynic wrote:
>
> I don't see any error in the output. What did you expect?
>
> At 14:30 7/27/2001, Tomas V.V.Cox wrote the following:
> --------------------------------------------------------------
> >During my test with the pushErrorHandling and popErrorHandling I found
> >strange behavoirs of the PHP array functions (I use last cvs php under
> >Linux).
> >
> >1) array_pop() bug:
> ><?php
> >$a = array();
> >$a[] = array('foo', 'bar');
> >print_r($a);
> >$a[] = array('foo2', 'bar2');
> >print_r($a);
> >$a = array_pop($a);
> >print_r($a);
> >?>
> >
> >The output:
> >Array
> >(
> > [0] => Array
> > (
> > [0] => foo
> > [1] => bar
> > )
> >
> >)
> >Array
> >(
> > [0] => Array
> > (
> > [0] => foo
> > [1] => bar
> > )
> >
> > [1] => Array
> > (
> > [0] => foo2
> > [1] => bar2
> > )
> >
> >)
Real output:
> >Array
> >(
> > [0] => foo2
> > [1] => bar2
> >)
Expected output:
Array
(
[0] => Array
(
[0] => foo
[1] => bar
)
)
> >2) The array[] statement fails to find the correct last value:
> ><?php
> >$a = array();
> >$a[] = array('foo', 'bar');
> >print_r($a);
> >$a[] = array('foo2', 'bar2');
> >print_r($a);
> >unset($a[sizeof($a) - 1]);
> >print_r($a);
> >$a[] = array('foo3', 'bar3');
> >print_r($a);
> >?>
> >
> >The output:
> >Array
> >(
> > [0] => Array
> > (
> > [0] => foo
> > [1] => bar
> > )
> >
> >)
> >Array
> >(
> > [0] => Array
> > (
> > [0] => foo
> > [1] => bar
> > )
> >
> > [1] => Array
> > (
> > [0] => foo2
> > [1] => bar2
> > )
> >
> >)
> >Array
> >(
> > [0] => Array
> > (
> > [0] => foo
> > [1] => bar
> > )
> >
> >)
Real output:
> >Array
> >(
> > [0] => Array
> > (
> > [0] => foo
> > [1] => bar
> > )
> >
> > [2] => Array
> > (
> > [0] => foo3
> > [1] => bar3
> > )
> >
> >)
> >
Expected output:
Array
(
[0] => Array
(
[0] => foo
[1] => bar
)
[1] => Array
(
[0] => foo3
[1] => bar3
)
)
Tomas V.V.Cox