Higher Order Functions

Route::get('/higher-order', function (){

    $removeSpaces = function ($string){
        return str_replace(' ','', $string);
    };

    $truncate = function ($callable, $string){
        return substr($callable($string),'1','4');

    };

    return $truncate($removeSpaces, "Higher Order functions");

});
Facebook Comments

You may also like