Home  >  Article  >  Backend Development  >  PHP排序疑点

PHP排序疑点

WBOY
WBOYOriginal
2016-06-13 12:41:07909browse

PHP排序疑问

本帖最后由 u010801782 于 2013-07-30 23:32:15 编辑
<br>
<?php <br />
function switchWeek($num){<br>
    switch ($num) {<br>
        case 1:<br>
            return '星期一';<br>
            break;<br>
        case 2:<br>
            return '星期二';<br>
            break;<br>
        case 3:<br>
            return '星期三';<br>
            break;<br>
        case 4:<br>
            return '星期四';<br>
            break;<br>
        case 5:<br>
            return '星期五';<br>
            break;<br>
        case 6:<br>
            return '星期六';<br>
            break;<br>
        case 7:<br>
            return '星期日';<br>
            break;<br>
         default:<br>
            return '';<br>
            break;<br>
    }<br>
}<br>
$con = mysql_connect("localhost","root","") or die('连接失败:'.mysql_error());<br>
mysql_select_db("testt");<br>
mysql_query('set names utf8');<br>
$sql = 'select * from news ';<br>
$result = mysql_query($sql);<br>
$array = array();<br>
while($row = mysql_fetch_array($result,MYSQL_ASSOC)){<br>
    $key = date('Y年m月d日',$row['sTime']).' '.switchWeek(date('N',$row['sTime']));<br>
    $array[$key][]=$row;<br>
}<br>
mysql_free_result($result);<br>
//var_dump($array);<br>
?><br>
nbsp;html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br>
 <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn