Translate Higher-Order Perl codes to PHP