所以我一直在做一個homelab儀表板,我需要知道如何在顯示我的php數組後添加一個響應式的「顯示更多」按鈕。我對開發相當陌生,而且更像是一種愛好。以下是我目前如何設置它,但是如果我在torrent數組中有超過15個項目,它會變得冗長。任何的意見都將會有幫助。查看更多按鈕爲php陣列
<div class="row">
<!--Downloading Section-->
<div class="col-lg-6 col-md-3 col-sm-12 col-xs-12">
<div class="info-box blue-bg">
<h3>Downloading <span class="speeds">
<?php
if ($client == "qbittorent"){
echo round(intval($global_info['dl_info_speed'])/1000, 2) . " kB/s";
} elseif ($client == "transmission"){
echo round(intval($global_info['downloadSpeed'])/1000, 2) . " kB/s";
}
?>
</span></h3>
<?php
if($torrents == null){
echo "There was a problem fetching torrents.";
} else {
if ($client == "qbittorrent"){
foreach($torrents as $torrent){
if($torrent['state'] == "downloading"){
echo $torrent['name'] . "<br>";
}
}
} elseif ($client == "transmission"){
foreach($torrents['torrents'] as $torrent){
if($torrent['status'] == "4"){
echo $torrent['name'] . "<br>";
}
}
}
}
?>
</div><!--/.info-box-->
</div><!--/.col-->
你可以用CSS隱藏輸出,並添加一個按鈕,該按鈕對JavaScript做出反應以放大隱藏的部分。 –