2011年11月27日

[PHP] 程式小技巧

[迴圈的使用]

//PHP3 or old
reset($attributes);
while (list($key, $value) = each($attributes)) {
    //do something
}
//PHP4
foreach ($attributes as $key => $value){
   //do something
}



[簡查重覆的資料]
SELECT username,COUNT(*)/*重複出現的次數*/ FROM member GROUP BY username HAVING COUNT(*) > 1 /*列出重複出現一次以上的資料*/

沒有留言:

張貼留言