我是php新手。我打算用php开发mikrotik api。我有PHP代码打印输出数组。我想得到输出到表。代码如下
<?php
require('../routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = false;
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
$API->write('/interface/getall');
$READ = $API->read(false);
$ARRAY = $API->parseResponse($READ);
print_r($ARRAY);
$API->disconnect();
}
?>
答案 0 :(得分:-1)
如果响应位于json中,则应使用json_decode()函数。如果响应只是一个数组,则可以使用foreach循环打印到html表。
<table>
<tr>
<th>Table column name</th>
<th>Table column name</th>
<th>Table column name</th>
</tr>
<?php
foreach($array as $data){
$var1=$data['var1']; //use your data here.
$var2=$data['var2'];
$var3=$data['var3'];
echo " <tr>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>
</tr>";
}
?>
</table>