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
 [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: Wed Jun 17 02:00:02 2026 UTC