I tested the following and it works on both PHP 5.2 and 5.3, however it is not documented anywhere as far as I can see, so I appreciate its use.
I have a function in a class called isValid, this checks the hash to see if the given value is in the set of valid values. There are some meanings that are valid but outdated; I would like my isValid function to update the passed value to the current one and return true.
Well, when I call it myself, I would like to use this method when it is used as a callback to array_filter.
Here's a test case that, as expected, leads to an array with values 2,3,4,5,6.
<?php $test = array(1, 2, 3, 4, 5); echo print_r(array_filter($test, 'maptest'), true); function maptest(&$value) { $value ++; return true; }
So, StackOverflow: is it allowed or is it undocumented functions that may disappear / stop working / cause errors in the future?
arrays reference php callback array-filter
philjohn
source share