< ?php $mes['rand'] = array("台詞1" , "台詞2" , "台詞3" , "台詞4" ); $mes['morning'] = array("台詞1" , "台詞2" , "台詞3" , "台詞4" ); $mes['night'] = array("台詞1" , "台詞2" , "台詞3" , "台詞4" ); $now_g = date('G'); $now_i = date('i'); if (preg_match("/^[1-6]{0,1}$/",$now_g)){ $now_g = 'sleep'; }; switch(true){ case $now_g == 'sleep' : $plist = array(); break; case ($now_g == '0')&&($now_i >= '30') : $plist = $mes['night']; break; case ($now_g == '7')&&($now_i <= '30') : $plist = $mes['morning']; break; default : $plist = $mes['rand']; break; }; if(! empty($plist)){ $key = array_rand($plist); $post = $plist[$key]; } ?>