mysql_fetch_lengths 的作用是判斷mysql_fetch_array ( ) , mysql_fetch_assoc ( ) , mysql_fetch_object ( )或mysql_fetch_row ( )的長度,如果成功就返回一個陳列,否則就返回false;
mysql_fetch_lengths的語法.
mysql_fetch_lengths(data)
參數.
data:必選就是mysql_query返回的值
來我們來看看實例.
<?
$sql = "SELECT * from Person WHERE Lastname='Refsnes'";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_row($result));
print_r(mysql_fetch_lengths($result));
?>
輸出結果.
Array ( [0] => Refsnes [1] => Kai Jim [2] => Taugata 2 [3] => 22 )Array ( [0] => 7 [1] => 7 [2] => 9 [3] => 2 )