-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsons.php
More file actions
39 lines (38 loc) · 1.22 KB
/
Jsons.php
File metadata and controls
39 lines (38 loc) · 1.22 KB
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
36
37
38
39
<?php
class Jsons
{
/**
* @param bool $status статус
* @param string $name_key имя ключа
* @param string $value значения ключей (необязательный параметр)
* @return json
*/
static function jsonOutput($status, $name_key, $value = null)
{
if(is_array($name_key) == true){
if($status == true){
echo json_encode([
"status"=>$status,
"payload"=>$name_key
]);
}else{
echo json_encode([
"status"=>$status,
"error"=>$name_key
]);
}
}else{
if($status == true){
echo json_encode([
"status"=>$status,
"payload"=>array_combine(explode(',',str_replace(' ', '',$name_key)) , explode(',', $value))
]);
}else{
echo json_encode([
"status"=>$status,
"error"=>array_combine(explode(',',str_replace(' ', '',$name_key)) , explode(',', $value))
]);
}
}
}
}