API2_query CPANEL Email listing output format - xmlapi

I used the following code PHP Code:

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;  

The output was in such a format {"cpanelresult":{"apiversion":2,"preevent":{"result":1},"data":[{"mtime":1411037171,"diskquota":"unlimited","_diskused":"54

I want the output to be in a table. Can anyone suggest how can I do so

Answers


There are two ways of doing this

First decode jason to Array

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);  

Second is getting output in Array instead of 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;  

Now you can print table from this array using foreach loop

echo "<table>";
foreach ($output as $key => $value){ 
      echo '<tr>';
      echo '<td>' . $key . '</td>';
      echo '<td>' . $value . '</td>';
      echo '</tr>';
 }
echo "</table>";

Need Your Help

Vb.net connection timeout while generating excel report

vb.net excel windows-8

I am trying to generate an excel report using the data from MSSQL. It is perfectly working on my pc(server) and all clients except those PC that has windows 8 installed(MS Office 2010 installed). I

ios expandable/collapsable view inside scrollview

ios objective-c uiscrollview

I am building a scrollview dynamically. Now in that scrollview , I would be giving user an option to "view more" maybe an icon sort of. On click of this icon the scrollview should show some data be...