在php中以表格格式显示curl输出

时间:2016-05-31 07:15:31

标签: php html curl

我使用以下代码使用Curl调用APU。

<?php
$user = 'airtest';
$pass = '******';
$msisdn = '+919923456';
$data = array("user" => "$user", "pass" => "$pass", "msisdn" => "$msisdn");
$data_string = json_encode($data);
$ch = curl_init('http://localhost:9080/vodaphone/trx');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

//echo $result;
$json = json_decode($result, true);

print_r($json);
?>

运行后,我将输出作为数组输出。

Array 
( 
 [code] => 0000 
 [actions] => Array 
     ( 
       [0] => Array 
      ( 
    [id] => 4857907090 
    [status] => COMPLETED 
    [type] => Receive 
    [account] => +919923456  
       ) 

      [1] => Array 
     ( 
    [id] => 4846161075 
    [status] => Done 
    [type] => Receive 
    [account] => +919923876 
     ) 

   )
)

但我希望这就像一个表格形式。任何人都可以帮助我以表格格式显示此数组。或任何信条链接。

0 个答案:

没有答案
相关问题