如何显示多个数组

时间:2014-04-25 23:06:01

标签: php arrays

我的脚本出了问题,我还在尝试找出如何显示多个数组,我只能显示不超过一个数组。

这是输出:

20140426100000

这是PHP:

<?php
$array = array(
    "10:00 AM",
    "11:00 AM",
    "12:00 PM",
    "12:30 PM",
    "2:00 PM",
    "2:30 PM",
    "9:00 PM",
    "11:00 PM",
    "12:00 AM",
    "12:30 AM",
    "1:00 AM",
    "1:30 AM",
    "2:00 AM",
    "11:00 PM",
    "12:00 AM",
    "12:30 AM",
    "1:00 AM",
);

// Save the output format
$DATE_FORMAT_STRING = "YmdHis";

// function to get the state
function getState($string){
    $ex = explode(" ",$string);
    return $ex[1];
}

// GET the current STAGE
$current_state = getState($array[0]);
$offset = 0;

foreach($array as $time){

    // Get the item state.  
    $this_state = getState($time);

    // check if we past a day? 
    if($current_state == "PM" && $this_state == "AM"){
        $offset++;
    }
$this_unix = strtotime($time) + (60 * 60 * 24 * $offset);
echo date($DATE_FORMAT_STRING, $this_unix);
    echo "<br></br";

    $current_state = $this_state;
}
?>

请告诉我如何显示多个这样显示的数组?

20140426100000
20140426110000
20140426120000
20140426123000
20140426140000
20140426143000
20140426210000
20140426230000
20140427000000
20140427003000
20140427010000
20140427013000
20140427020000
20140427110000
20140427120000
20140427123000
20140427130000

1 个答案:

答案 0 :(得分:1)

Your code works fine.您的错误是HTML错误。您错过了其中一个<br>代码的结束括号。这会导致您无法在页面上看到输出。

echo "<br></br"; <-- HERE