php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #8106 array_pop problem when using against an array returned from a class
Submitted: 2000-12-04 21:10 UTC Modified: 2001-03-17 00:33 UTC
From: drew at cwa dot co dot nz Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.3pl1 OS: Debian GNU/Linux
Private report: No CVE-ID: None
 [2000-12-04 21:10 UTC] drew at cwa dot co dot nz
Seems to return no TRUE value when using array_pop () on an array returned by a class.

Code Example:

<?
class Form {

      function parse ($arg) {
      
               ereg("(.*)&\[(.?)\]", $arg, $query);
               
               return $query;

      }

}

$form = new Form;

$output = $form->parse($QUERY_STRING);

$number = array_pop($output);

if ($number) { echo "\$number exists"; }

foreach ($output as $tmp) {
        if (($tmp)&&($tmp != $QUERY_STRING)) {
           echo "$tmp<Br>";
        }
}

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-05 06:15 UTC] sniper@php.net
If you pass a non-array to array_pop() it just displays an
error message. 

After checking the sources for this function, it looks
like it doesn't return anything in case of this error.

Do you mean it should return FALSE in case of this error?
(I think it should)

But if you pass an empty array for array_pop() it
won't return anything but will not display any error 
messages either which I think is the right behaviour. 

--Jani


 [2000-12-07 03:13 UTC] sniper@php.net
Reclassified as documentation problem.

array_pop($arr) (and array_shift($arr) ?) returns NULL in case the $arr is
an empty array or it isn't an array at all. 


--Jani
 [2001-03-17 00:33 UTC] jmcastagnetto@php.net
Fixed in manual (CVS)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC