本文介紹了來自爆炸數組的 PHP 表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有這樣的數據:
something something_description, something2 something2_description, something3 something3_description...
現在我需要用 PHP 來獲取表格:
And now I need with PHP to get table as:
<tr><td>something</td><td>something_description</td></tr>
<tr><td>something2</td><td>something2_decription</td></tr>
我不知道會有多少something"和something_decriptions",所以我需要設置一些循環.
I don't know how many "something" and "something_decriptions" will it be so I need to set some loop.
現在我有這個代碼:
$data = explode(',',$query);
從中我會得到如下數組:
from that I will get array like:
[0] => something something_description
現在我怎樣才能把它放到表格中?
Now how can I put this into table?
在網上我找到了一些將數組排序到表格的例子,但這是在explode"中還有一個explode"
On net I found some examples for sorting array to table, but this is with one more "explode" inside "explode"
我需要一些幫助.
推薦答案
可能你正在尋找這個:
$data = explode(',',$query);
echo '<table>';
foreach($data as $row){
echo '<tr>';
$row = explode(' ',$row);
foreach($row as $cell){
echo '<td>';
echo $cell;
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
這篇關于來自爆炸數組的 PHP 表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!