PHP code example of emileperron / universal-identifier

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

    

emileperron / universal-identifier example snippets



// This will output the string's identifier: "de719c460cc38eddfb39fe286882a042be247e5d091fd8e4aed01daf9d3a5513"
echo universal_identifier("my string");

// Same thing goes for all primitives;
echo universal_identifier(150); // "7d3c18bc20c238917421291209ad0d17c83be19e4c214abcf09160af2949f591"
echo universal_identifier(0.55f); // "1c3d577cd8a09945100ac46c061835db1691907bc40f01931d5083ec7fb69def"
// etc...


$yourArray = [
	"foo" => "bar",
	"foos" => [
		"bar1", 
		"bar2"
	],
	"anotherKey" => "value",
];

// This will output the array's identifier: "7ef0675c80dd9ae9f9fed4a786f8c0641d14a646cc580de1690f62a803e54f89"
echo universal_identifier($yourArray);

// Even if you change the order of the array's keys, the identifier will remain the same (this does not apply to numerically-indexed arrays, where the order actually matters).
// Ex.:
ksort($yourArray);
// This will still output the same identifier: "7ef0675c80dd9ae9f9fed4a786f8c0641d14a646cc580de1690f62a803e54f89"
echo universal_identifier($yourArray);