From 879a6237b186768356f99caf992f0d25d5ec8612 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sun, 5 Dec 2021 16:38:49 +0100 Subject: Commit --- app/genealogy/search/state/data.json/index.php | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/genealogy/search/state/data.json/index.php (limited to 'app/genealogy/search/state/data.json/index.php') diff --git a/app/genealogy/search/state/data.json/index.php b/app/genealogy/search/state/data.json/index.php new file mode 100644 index 0000000..e0bad67 --- /dev/null +++ b/app/genealogy/search/state/data.json/index.php @@ -0,0 +1,39 @@ + $person) { + if (isset($person["birth"]["place"]) && isset($person["birth"]["place"]["state"])) { + if (isset($counts[$person["birth"]["place"]["state"]])) { + $counts[$person["birth"]["place"]["state"]]++; + } else { + $counts[$person["birth"]["place"]["state"]] = 1; + } + if (!in_array($person["birth"]["place"]["state"], $names)) { + $names[] = $person["birth"]["place"]["state"]; + } + } +} + +foreach ($names as $name) { + $arr[] = [ + 'name' => $name, + 'occurrences' => $counts[$name] . " personne" . ($counts[$name] > 1 ? "s" : "") + ]; +} + +echo(json_encode($arr)); \ No newline at end of file -- cgit