PHP code example of phore / core

1. Go to this page and download the library: Download phore/core 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/ */

    

phore / core example snippets


$data = ["some"=>["path"=>"data"]];

assert( "data" === phore_pluck("some.path", $data) );

assert( "data" === phore_pluck(["some", "path"], $data) );

assert( "fail" === phore_pluck("unknown", $data, "fail") );
phore_pluck("unknown", $data, new InvalidArgumentException("path missing"));


// if default is array, phore_pluck will ensure to return array
assert ( [] == phore_pluck("some.path", $data, []) );


$input = ["a", "remove"];


$out = phore_array_transform($input, function ($key, $value) {
    if ($key == "remove")
        return null;
    return ["x"=>"y"];
});

assert([["x"=>"y"]] == $out);