Consider the following:
function bracketStrip($arrItem){
return trim($arrItem, '()');
}
$arr = array('(20)','(15)','(6)','(1)');
$arr = array_map("bracketStrip", $arr);
echo '<pre>'.print_r($arr, true);
Which outputs the values with bracket removed. Fair enough. We can clearly see what's going on.
Now, I have often pondered.. could I not simply integrate that function into the array_map itself. So my first thought is, perhaps using the lambda style create_function().. but then I automatically ask, could I use create_function as a callback? According to this page in the php manual, apparently, yes.
"Apart from common user-defined function, create_function() can also be used to create an anonymous callback function."
Yet I look at the examples shown, and I cannot find the format I have in mind, which is something like this:
array_map("create_function(return trim($arr, '()')", $arr);
With the above line, I get the following warning message:
"Warning: array_map() [function.array-map]: The first argument, 'create_function(return trim(Array, '()')', should be either NULL or a valid callback"
So I am asusming one of two things here.. either
a) It is syntactically incorrect (as in, it is an invalid callback) - or -
b) simply not possible
Any thoughts or suggestions? The whole idea here is since I only want to trim something, I'm trying to integrate it into a function that could be streamlined within the array_map function.