我知道
mysqli_fetch_assoc,
mysqli_fetch_array,
mysqli_fetch
但是,MYSQLI_BOTH
等于 mysqli_fetch_array
还是它们实际上不同?
最佳答案
来自 PHP 手册:
By using the MYSQLI_ASSOC constant this function will behave identically to the mysqli_fetch_assoc(), while MYSQLI_NUM will behave identically to the mysqli_fetch_row() function. The final option MYSQLI_BOTH will create a single array with the attributes of both.
这些是可选参数,用于指示将返回什么类型的数组
。
这里是基本的例子:
$result->fetch_array(MYSQLI_NUM);
array(
0 => "val 1",
1 => "val 2"
);
$result->fetch_array(MYSQLI_ASSOC);
array(
'key0' => "val 1",
'key1' => "val 2"
);
$result->fetch_array(MYSQLI_BOTH);
array(
0 => "val 1",
'key0' => "val 1",
1 => "val 2",
'key1' => "val 2"
);
关于php - mysqli_fetch_array 和 MYSQLI_BOTH 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34648767/