小编Cha*_*jay的帖子

如何在 PHP 中将 HTML 表转换为 JSON

我正在尝试将一些 html 转换为数组,然后转换为 json 字符串。

我正在基于此参考进行开发:https://www.codeproject.com/Tips/1074174/Simple-Way-to-Convert-HTML-Table-Data-into-PHP-Arr

这是基本的 table/html,我想将其转换为 JSON。

<table class="table-list table table-responsive table-striped">
<thead>
    <tr>
        <th class="coll-1 name">name</th>
        <th class="coll-2">height</th>
        <th class="coll-3">weight</th>
        <th class="coll-date">date</th>
        <th class="coll-4"><span class="info">info</span></th>
        <th class="coll-5">country</th>
    </tr>
</thead>
<tbody>
<tr>
    <td class="coll-1 name">
        <a href="/username/Jhon Doe/" class="icon"><i class="flaticon-user"></i></a>
        <a href="/username/Jhon Doe/">Jhon Doe</a>
    </td>
    <td class="coll-2 height">45</td>
    <td class="coll-3 weight">50</td>
    <td class="coll-date">9am May. 16th</td>
    <td class="coll-4 size mob-info">abcd</td>
    <td class="coll-5 country"><a href="/country/CA/">CA</a></td>
</tr>
<tr>
    <td class="coll-1 name">
        <a href="/username/Kasim Shk/" class="icon"><i class="flaticon-user"></i></a>
        <a href="/username/Kasim Shk/">Kasim Shk</a> …
Run Code Online (Sandbox Code Playgroud)

html php parsing json domdocument

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

domdocument ×1

html ×1

json ×1

parsing ×1

php ×1