🎉 - Début développement plugin CustomTreeFile
This commit is contained in:
32
functions.php
Normal file
32
functions.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
function array_merge_recursive_distinct(array ...$arrays): array {
|
||||
$merged = [];
|
||||
|
||||
foreach ($arrays as $array) {
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key])) {
|
||||
// Appel récursif pour fusionner les tableaux enfants
|
||||
$merged[$key] = array_merge_recursive_distinct($merged[$key], $value);
|
||||
} elseif (is_array($value) && !array_key_exists($key, $merged)) {
|
||||
// Ajouter les nouveaux tableaux si la clé n'existe pas encore
|
||||
$merged[$key] = $value;
|
||||
} elseif (!is_array($value)) {
|
||||
if (is_int($key)) {
|
||||
// Ajouter une valeur unique dans les clés numériques
|
||||
if (!in_array($value, $merged, true)) {
|
||||
$merged[] = $value;
|
||||
}
|
||||
} else {
|
||||
// Écraser pour les clés associatives
|
||||
$merged[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $merged;
|
||||
}
|
||||
|
||||
function is_dir_empty($dir): bool {
|
||||
return (count(scandir($dir)) == 2);
|
||||
}
|
Reference in New Issue
Block a user