フォルダー(ウォッチフォルダー)の内容を確認するwebappを作成しました。 今、私は<tr></tr>
の要素を作成時間に基づいて色付けしようとしています。 tr要素は黄色であるべきのように...foreach内でphp change css class
コードは次のようになります。
<?php
$currentTimeFormat = date("d.m.Y H:i",$currentTime);
echo "current time " . $currentTimeFormat;
if (count($watchFolder) > 0) {
echo '<table class=\'table table-reponsive table-bordered\'>';
echo '<tbody>';
foreach ($watchFolder as $key => $value) {
$currentWatchPath = $watchFolderPath . $key;
if(strtotime($currentWatchPath) < strtotime('-1 minute')) {
$class = "redtest";
}
if(strtotime($currentWatchPath) < strtotime('-1 hour')) {
$class = "bluetest";
}
if(strtotime($currentWatchPath) < strtotime('-1 day')) { # Older than one day
$class = "greentest";
}
echo '<thead class=\'thead-inverse\'>
<tr>
<th scope=\'row\' class='.$class.'>'.$key.' | Last change '.date("d.m.Y H:i", filemtime($currentWatchPath)).'</th>
</tr>
</thead>';
foreach ($value as $key => $valueSub) {
$currentWatchPath2 = $currentWatchPath . '\\' . $key;
echo '<tr>
<td class=\'grey\'>
<span class="glyphicon glyphicon-arrow-right"></span> '.$key.' | Last change '.date("d.m.Y H:i", filemtime($currentWatchPath2)).'</td>
</tr>';
foreach ($valueSub as $content) {
$currentWatchPath3 = $currentWatchPath2 . '\\' . $content;
echo '<tr>
<td>
<span class="glyphicon glyphicon-arrow-right"></span> '.$content.' | Last change '.date("d.m.Y H:i", filemtime($currentWatchPath3)).'</td>
</tr>';
}
}
}
echo '</tbody>';
echo '</table>';
}
?>
の$ watchfolderは、特定のパスのすべてのフォルダを保持する配列です。
watchfolders(とサブフォルダ)とその時刻を取得できます。
しかし、各フォルダの作成時間に基づいてtr要素を着色することは適切に機能しません。私の場合、新しいフォルダを作成してもすべてのtr要素は緑色に着色されます。
いくつかのアドバイスはクールです。
あなたが私のコードを改善できると思うなら、あなたは大歓迎です!