get rid of ugly code construct

This commit is contained in:
redmatrix 2016-08-16 19:00:38 -07:00
parent 70150718c5
commit a2873c18ca

View File

@ -118,11 +118,7 @@ require_once('include/api_auth.php');
break; break;
case "json": case "json":
header ("Content-Type: application/json"); header ("Content-Type: application/json");
foreach($r as $rr) { $json = json_encode((is_array($r[0])) ? $r[0] : array());
if(! $rr)
$rr = array();
$json = json_encode($rr);
}
// Lookup JSONP to understand these lines. They provide cross-domain AJAX ability. // Lookup JSONP to understand these lines. They provide cross-domain AJAX ability.
if ($_GET['callback']) if ($_GET['callback'])
$json = $_GET['callback'] . '(' . $json . ')' ; $json = $_GET['callback'] . '(' . $json . ')' ;
@ -137,9 +133,6 @@ require_once('include/api_auth.php');
return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r; return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
break; break;
case "as": case "as":
//header ("Content-Type: application/json");
//foreach($r as $rr)
// return json_encode($rr);
return json_encode($r); return json_encode($r);
break; break;