-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
59 lines (50 loc) · 1.4 KB
/
test.php
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
$url = 'https://payments.baxipay.com.ng/api/baxipay/billers/category/all';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'x-api-key: 5adea9-044a85-708016-7ae662-646d59',
'Content-Type: application/json'
]);
$response = curl_exec($curl);
curl_close($curl);
$json = $response . PHP_EOL;
function printValues($arr) {
global $count;
global $values;
// Check input is an array
if(!is_array($arr)){
die("ERROR: Input is not an array");
}
/*
Loop through array, if value is itself an array recursively call the
function else add the value found to the output items array,
and increment counter by 1 for each value found
*/
foreach($arr as $key=>$value){
if(is_array($value)){
printValues($value);
} else{
$values[] = $value;
$count++;
}
}
// Return total count and values found in array
return array('total' => $count, 'values' => $values);
}
$arr = json_decode($json,TRUE);
//print_r($arr);
//echo "<h3>" . $result["total"] . " value(s) found: </h3>";
//echo implode("<br>", $result["values"]);
foreach ($arr as $key => $value) {
if (!is_array($value)) {
// echo $key . '=>' . $value . '<br />';
} else {
foreach ($value as $key => $val) {
foreach($val as $key => $va){
echo $key. '=>' .$va. '</br>';
}
}
}
}
?>