Bug #71240 [Opn->Nab]: array_filter byref value in callable no longer working

From: Date: Tue, 29 Dec 2015 20:57:13 +0000
Subject: Bug #71240 [Opn->Nab]: array_filter byref value in callable no longer working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198288@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71240&edit=1 ID: 71240 Updated by: requinix@php.net Reported by: donatj at gmail dot com Summary: array_filter byref value in callable no longer working -Status: Open +Status: Not a bug Type: Bug Package: *General Issues PHP Version: 7.0.1 Block user comment: N Private report: N New Comment: I don't see anything to suggest that was supported in the first place. There aren't even user comments doing that. Besides, if you want to alter the array values then array_map() is more appropriate. Previous Comments: ------------------------------------------------------------------------ [2015-12-29 20:05:12] donatj at gmail dot com Description: ------------ It would appear that passing by reference in the callable of array_filter no longer functions as expected. I can find no documentation of this change on the array_filter page. The expected result is seen in 5.3 -> 5.6 Test script: --------------- <?php $files = array('AAA', 'BBB', 'CcC'); $files = array_filter($files, function ( &$path ) { $path = strtolower($path); return true; }); print_r($files); Expected result: ---------------- Array ( [0] => aaa [1] => bbb [2] => ccc ) Actual result: -------------- Array ( [0] => AAA [1] => BBB [2] => CcC ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71240&edit=1

« previous php.bugs (#198288) next »