结果NuSoap到PHP的字符串

时间:2016-06-16 22:55:23

标签: php nusoap

我是php初学者并开始学习nusoap。 这是我的代码:

<?php
include_once('nusoap/nusoap.php');
include_once('nusoap/class.wsdlcache.php');


$url = 'http://localhost:8082/ws/server.php?wsdl';

$client = new nusoap_client($url, true);

$proxy = $client->getProxy();

$username = 'admin';
$password = 'admin123';

$token = $proxy->GetToken($username, $password);

//this code to display ListTable

$table = $proxy->ListTable($token);
?>

如何显示表格列表?如果我尝试使用此代码: print_r($ table),我得到了这个结果:

    Array
(
    [error_code] => 0
    [error_desc] => 
    [result] => Array
        (
            [0] => Array
                (
                    [table] => student
                    [category] => Ref
                    [information] => student information
                )

            [1] => Array
                (
                    [table] => id_number
                    [category] => Ref
                    [information] => Student ID Number
                )

            [2] => Array
                (
                    [table] => Address
                    [category] => Ref
                    [information] => Student Address
                )
    )
)

如果我使用此代码打印值: print_r($ table,TRUE)但结果为空白页。

我希望输出如下:

<table border='1'>
  <tr>
    <td>Table</td>
    <td>Category</td>
    <td>Information</td>
  </tr>
  <tr>
    <td>student</td>
    <td>Ref</td>
    <td>student information</td>
  </tr>
  <tr>
    <td>id_number</td>
    <td>Ref</td>
    <td>student id number</td>
  </tr>
  <tr>
    <td>information</td>
    <td>Ref</td>
    <td>student address</td>
  </tr>

</table>

请帮忙。感谢。

1 个答案:

答案 0 :(得分:0)

尝试

<?php

echo "<table><tr>";

foreach($table['result'] as $r){
echo "<td>".$r['table']."</td>";
echo "<td>".$r['category']."</td>";
echo "<td>".$r['information']."</td>";
}

echo "</tr></table>";

?>