문제

NUSOAP 확장이 나에게 좋은 배열로 바뀌 었다는 비누 결과 세트가 있습니다. 나는 내가 원하는 것을 위해 그것을 반복하는 긴 길을 긁을 수 있다고 확신한다. 그러나 특정 데이터 요소를 통과하는 더 빠른 방법이 있어야한다. 배열은 다음과 같습니다.

Array
(
    [xxxResult] => Array
    (
        [NewDataSet] => Array
        (
            [Table] => Array
            (
                [0] => Array
                (
                    [ID] => 472
                    [Name] => abc
                    [Weight] => 0.15
                    [AppID] => 5133356895445
                )

                [1] => Array
                (
                    [ID] => 7396
                    [Name] => def
                    [Weight] => 0.11
                    [AppID] => 51348575554
                )

            )

        )

    )

)

그래서 내가하고 싶은 것은 단순히 내가 얻을 수 있도록 단순히 루프입니다.

<tr>
    <td>[ID]</td>
    <td>[Name]</td>
    <td>[Weight]</td>
    <td>[AppID]</td>
</tr>

... 각 테이블 행에 대해.

xxxresult] [newdataset] [표] [0] [id] 등보다 더 빠른 방법이 있어야합니다.

도움이 되었습니까?

해결책

이와 같이?

<?php

$tables = $soapResult['xxxResult']['NewDataSet']['Table'];

foreach ($tables as $table) {

?>
    <tr>
        <td><?php echo $table['ID']; ?></td>
        <td><?php echo $table['Name']; ?></td>
        <td><?php echo $table['Weight']; ?></td>
        <td><?php echo $table['AppID']; ?></td>
    </tr>
<?php

}

다른 팁

처럼:

 for ($row = 0; $row < 2; $row++){
echo "<tr>";

for ($col = 0; $col < 4; $col++)
{
    echo "<td>".$myarray[$row][$col]."</td>";
}

echo "</tr>";

}

물론 행 또는 콜이 변경되는 경우 배열의 길이를 얻어야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top