From d0982c5250d2e33c824ddccb8bd245ca39faa724 Mon Sep 17 00:00:00 2001 From: Minteck Date: Wed, 12 Jan 2022 18:58:54 +0100 Subject: Upadte --- search/lastname/data.json/index.php | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 search/lastname/data.json/index.php (limited to 'search/lastname/data.json/index.php') diff --git a/search/lastname/data.json/index.php b/search/lastname/data.json/index.php new file mode 100644 index 0000000..861b791 --- /dev/null +++ b/search/lastname/data.json/index.php @@ -0,0 +1,39 @@ + $person) { + $name = ucfirst(strtolower($person["famname"])); + + if (isset($counts[$name])) { + $counts[$name]++; + } else { + $counts[$name] = 1; + } + if (!in_array($name, $names)) { + $names[] = $name; + } +} + +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