Had to deploy some PHP code onto a shared server with only PHP5.2.8. All code works EXCEPT for the preg_filter() call which was added in 5.3+ (and against which the code was written).
Can anyone recommend an easy substitute for preg_filter() in PHP5.2?
PHP manual says that
preg_filter()is identical topreg_replace()except it only returns the matches.So, you can use a combination of
preg_replaceandarray_diffto get results like preg_filter in PHP 5.2.x. Do it like this:This gives the output (with xDebug installed):
Which is same as
preg_filter()output: