MySQL數(shù)組函數(shù)--mysql_fetch_array()
MySQL有一類獨(dú)特的函數(shù),稱為MySQL數(shù)組函數(shù),下面為您介紹的就是其中的MySQL數(shù)組函數(shù)--mysql_fetch_array()。
mysql_fetch_array 從結(jié)果集中取得一行作為關(guān)聯(lián)數(shù)組,或數(shù)字?jǐn)?shù)組,或二者兼有。
依次調(diào)用此函數(shù)也會(huì)返回結(jié)果集的下一行。
該MySQL數(shù)組函數(shù)語(yǔ)法:mysql_fetch_array(resource result, result type)
返回結(jié)果一般為:
Array ( [0] => 1 [ID] => 1 [1] => 58.215.76.161 [IP] => 58.215.76.161 [2] => linux [description] => linux [3] => 1 [4] => http [protocol] => http [5] => 80 [port] => 80 [6] => http [7] => check_http [command] => check_http )
如果只需要關(guān)聯(lián)數(shù)組則命令參數(shù)為
mysql_fetch_array($rs,MYSQL_ASSOC) 相當(dāng)于函數(shù)mysql_fetch_assoc()。
返回結(jié)果為
Array ( [ID] => 1 [IP] => 58.215.76.161 [description] => linux [protocol] => http [port] => 80 [command] => check_http )
如果只需要數(shù)字?jǐn)?shù)組則命令參數(shù)為
mysql_fetch_array($rs,MYSQL_NUM) 相當(dāng)于函數(shù)mysql_fetch_row().
返回結(jié)果為
Array ( [0] => 1 [1] => 58.215.76.161 [2] => linux [3] => 1 [4] => http [5] => 80 [6] => http [7] => check_http )
【編輯推薦】