How can I use PHP closure function like function() use() on PHP 5.2 version as it has no support for anonymous functions?
Currently my code is something like below
Php supports anonymous functions since 5.3.0, read about it in manual.
You could use create_function
but you should avoid this (for example because of this comment) and it's practically the same as eval... One bad enclosure and you'll make your sources vulnerable. It's also evaluted on runtime, not on compilation time what can decrease performance and may cause fatal error in the middle of included file.
Rather declare that function somewhere, it'll be more effective.