PHP code example of functional-php / named-parameters

1. Go to this page and download the library: Download functional-php/named-parameters library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

functional-php / named-parameters example snippets


function return_array($a, $b, $c) {
    return [$a, $b, $c];
}

use function FunctionalPHP\NamedParameters\call_user_func_array_np;

// traditional call with positional arguments
call_user_func_array_np('return_array', [1, 2, 3]);

// named arguments in the correct order
call_user_func_array_np('return_array', ['a' => 1, 'b' => 2, 'c' => 3]);

// named arguments in random order
call_user_func_array_np('return_array', ['c' => 3, 'a' => 1, 'b' => 2]);
call_user_func_array_np('return_array', ['c' => 3, 'b' => 2, 'a' => 1]);