php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42753 Example script contains errors
Submitted: 2007-09-25 08:01 UTC Modified: 2007-09-25 08:22 UTC
From: plonk at doramail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: MacOS
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: plonk at doramail dot com
New email:
PHP Version: OS:

 

 [2007-09-25 08:01 UTC] plonk at doramail dot com
Description:
------------
Example 2466 on the "trim" explanation page makes no sense, function "trim_value" isn't called anywhere, instead it uses "var_dump" from the example on top of it:

<?php
function trim_value(&$value)
{
    $value = trim($value);
}

$fruit = array('apple','banana ', ' cranberry ');
var_dump($fruit);

array_walk($fruit, 'trim_value');
var_dump($fruit);

?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-25 08:22 UTC] rquadling@php.net
The example works great.

Here is the output.

array(3) {
  [0]=>
  string(5) "apple"
  [1]=>
  string(7) "banana "
  [2]=>
  string(11) " cranberry "
}
array(3) {
  [0]=>
  string(5) "apple"
  [1]=>
  string(6) "banana"
  [2]=>
  string(9) "cranberry"
}

Notice the different lengths for banana and cranberry.

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Jun 26 02:00:01 2026 UTC