我使用了以下代码PHP代码:
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("json");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
print $output;
输出为这样的格式{"cpanellresult":{"apiversion":2,"preevent":"结果":1},"data":[{"mtime":1411037171,"diskquota":"unlimited","_diskused":"54
我希望输出在一个表中。有人能提出建议吗我该怎么做
有两种方法可以实现
首先解码杰森阵列
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("json");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
$output = json_decode($output)
print_r($output);
第二个是在Array而不是jason 中获得输出
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("array");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
print $output;
现在您可以使用foreach循环从这个数组打印表格
echo "<table>";
foreach ($output as $key => $value){
echo '<tr>';
echo '<td>' . $key . '</td>';
echo '<td>' . $value . '</td>';
echo '</tr>';
}
echo "</table>";