Site icon JDK Solutions

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
Exit mobile version