php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77878 array_filter example improvement
Submitted: 2019-04-11 16:52 UTC Modified: 2019-04-12 09:16 UTC
From: php-bugs at allenjb dot me dot uk Assigned: peehaa (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2019-04-11 16:52 UTC] php-bugs at allenjb dot me dot uk
Description:
------------
The 2nd example for array_filter shows its usage without a callback to filter empty array elements.

The example does not include entries for zero values, which could cause issues for newer developers who aren't familiar with PHP's type system.

I would suggest updating the example to include zero values:

$entry = array(
             0 => 'foo',
             1 => false,
             2 => -1,
             3 => null,
             4 => '',
             5 => '0',
             6 => 0,
          );

print_r(array_filter($entry));


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-12 09:14 UTC] peehaa@php.net
Automatic comment from SVN on behalf of peehaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=347206
Log: Adds examples of array_filter behavior with 0 string and integer. Closes #77878
 [2019-04-12 09:16 UTC] peehaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: peehaa
 [2019-04-12 09:16 UTC] peehaa@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 01:01:31 2024 UTC