<?php
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    require_once '../data.php';

    $dataBo = array();

    $select_data = "SELECT * FROM justicewonder WHERE is_result = 1 AND trashed = 0 ORDER BY id DESC";
    $query = mysqli_query($data, $select_data);
    $x = 1;
    while ($fetch = mysqli_fetch_assoc($query)) {
        $regex = '/(?<!\ )[0-9]/';
        $prize1 = preg_replace($regex, '<li>\\0</li> ' . '', $fetch['prize1']);

        $dataBo[] = array(
            $x++,
            '#' . $fetch['id'],
            '<ul>' . $prize1 . '</ul>',
            '<span class="text-capitalize">' . date("F d l, Y", strtotime($fetch['mulaitgl'])) . '</span>',
            '₫' . number_format($fetch['top_prize'])

        );
    }

    header('Content-Type: application/json');
    $new_data = array("data" => $dataBo);
    echo json_encode($new_data);
}
