php序列化数据按升序时间戳排序?

时间:2016-02-18 09:10:28

标签: php serialization foreach

我正在使用包含时间戳的序列化数据,我想按时间戳升序整理我的结果。为了获得“a”时间戳,我在foreach中使用了一个爆炸功能,但我不知道如何“选择”显示的顺序......

<?php
$sql_getLeft = "SELECT * FROM worksheets WHERE status = 0 ORDER BY left_date_record ASC";
$req_getLeft = $cnx->query($sql_getLeft);
$req_getLeft->setFetchMode(PDO::FETCH_OBJ);

$cid = 0;
while ($check_left = $req_getLeft->fetch()) {
    $series = str_replace('-', '', $check_left->train_type);

    $pos_lane = unserialize($check_left->position_history);

    $i = 0;

    foreach ($pos_lane as $item) {
        $exp = explode("|", $pos_lane[$i]);

        if ($exp[2] > $currentdate_tomorrow_midnight && $exp[2] < $currentdate_tomorrow_midnight_7hoursplus) {
            ?>

            <tr style="background-color: #FFF;border:1px solid black;" data-id="<?php echo $cid; ?>">
                <td data-field="time" style="border:1px solid black;text-align:center;vertical-align:middle;width:65px;"><?php echo createtimestring($exp[2]); ?></td>
            <td data-field="isum" style="border:1px solid black;text-align:center;"></td>
            <td data-field="train" style="border:1px solid black;text-align:center;<?php if ($series == "Z") {
            echo "background-color: #0C8CE1; color: #FFF;";
        } elseif ($series == "X") {
            echo "background-color: #F4F46B;  color: #000;";
        } elseif ($series == "BB") {
            echo "background-color: #FFF;  color: #CE0808;";
        } elseif ($series == "B") {
            echo "background-color: #CE0808;  color: #000;";
        } ?>"><?php echo $check_left->train_id; ?></td>
            <td data-field="from" style="border:1px solid black;text-align:center;"><?php echo $exp[0]; ?></td>
            <td data-field="to" style="border:1px solid black;text-align:center;"><?php echo $exp[1]; ?></td>
            <td colspan="2" data-field="comments" style="border:1px solid black;text-align:center;">
        <?php if (strlen($check_left->observations) > 5) {
            echo $check_left->observations;
        } ?>
            </td>
        </tr>

        <?php
    }

    $i++;
}

$cid++;
}
?>

0 个答案:

没有答案