-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
35 lines (23 loc) · 705 Bytes
/
function.php
File metadata and controls
35 lines (23 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
function getFile($jsonFilePath, $isJson = true){
if ($isJson) {
if (file_exists($jsonFilePath)) {
$jsonContent = file_get_contents($jsonFilePath);
$data = json_decode($jsonContent, true);
if ($data === null) {
return "Erreur de décodage JSON";
} else {
return $data;
}
} else {
return "Le fichier JSON n'existe pas.";
}
} else {
if (file_exists($jsonFilePath)) {
$jsonContent = file_get_contents($jsonFilePath);
return $jsonContent;
} else {
return "Le fichier YML n'existe pas.";
}
}
}