Skip to content

Instantly share code, notes, and snippets.

@lazyfrosch
Created March 13, 2020 08:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazyfrosch/a2058e41db98a77cf25ddefe814bad94 to your computer and use it in GitHub Desktop.
Save lazyfrosch/a2058e41db98a77cf25ddefe814bad94 to your computer and use it in GitHub Desktop.
<?php
$list = array(array("key1"=>"value","key4"=>"value"),array("key3"=>"value"),array("key2"=>"value"));
function uniqueKeysOfList($list) {
$keys = [];
foreach ($list as $obj) {
foreach ($obj as $k => $v) {
$keys[$k] = 1;
}
}
return array_keys($keys);
}
var_export(uniqueKeysOfList($list));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment