How PHP or mysql traverses

this is the foreground display page, and the business logic goes like this:

(Input)
6

from=018

18:
111222.....

clipboard.png

Mar.11,2021

there is no high-end way to judge whether it is empty or not. It is simple and rude


Let's see if this is all right.
represents the value of input as an array, and then all the input received by the background are in one array

$hotels = array();
$arr = $_POST['arr'];

foreach ($arr as $k => $v) {
    if($k%3 == 0){
        if($v){
            if(!$arr[$k+1] || !$arr[$k+2]){
                echo json_encode(array(
                    "code" => -1,
                    "msg"  => "",
                ));
                die;
            }
            $hotels[] = array(
                "name" => $v,
                "cost" => $arr[$k+1],
                "time" => $arr[$k+2],
            );
        }else{
            $hotels[] = array(0, 0, 0);
        }
    }
}
echo json_encode(array(
    "code" => 0,
    "msg"  => "success",
));
The parameters in the

form can be written as an array: < input type= "text" name= "time []" / >, you can learn about this

Menu