ID: 36451 User updated by: epoc_32 at yahoo dot co dot ukXXX Reported By: epoc_32 at yahoo dot co dot ukXXX -Status: Bogus +Status: Open Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.1.2 New Comment:
This isn't a support question, I'm not asking for help in a script. It's a minor bug in the way the script is parsed when nesting functions. The code in which I discovered the bug used explode() inside array_pop(), I only used my example code to simplyfy things. array_pop() is returning the last element of the array but isn't truncating the array inside it. As I say, things work as expected in PHP4 so why would PHP5 return the last element of the array without truncating it? Previous Comments: ------------------------------------------------------------------------ [2006-02-19 13:38:50] [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. http://php.net/references ------------------------------------------------------------------------ [2006-02-19 02:50:39] epoc_32 at yahoo dot co dot ukXXX Description: ------------ If you create an array inside array_pop(), expecting that array to be popped then it isn't even though the last element of that array is returned as expected. Creating the array on the previous line makes array_pop() behave as expected. This behaviour doesn't occur in PHP4.3.x on FreeBSD. I only noticed it when I upgraded to PHP 5.1.2 on my home WinXP machine though it's possible it was broken but I didn't notice it in 5.0.x Reproduce code: --------------- $a=array(0, 1, 2, 3, 4, 5); // Set array first. $offcut=array_pop($a); // Then pop array. $length=count($a); echo "<pre>Array offcut: " .$offcut."\nArray length: " .$length."\nLast element: " .$a[$length-1]."</pre>\n"; $offcut=array_pop($a=array(0, 1, 2, 3, 4, 5)); // Set and pop at the same time. $length=count($a); echo "<pre>Array offcut: " .$offcut."\nArray length: " .$length."\nLast element: " .$a[$length-1]."</pre>\n"; Expected result: ---------------- Array offcut: 5 Array length: 5 Last element: 4 Array offcut: 5 Array length: 5 Last element: 4 Actual result: -------------- Array offcut: 5 Array length: 5 Last element: 4 Array offcut: 5 Array length: 6 Last element: 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36451&edit=1