Mysqli fetch_assoc vs fetch_array

前端 未结 4 1924
心在旅途
心在旅途 2020-12-03 05:33

When I\'m returning one row from a table, to gather the results I usually use e.g.:

$info = $result->fetch_assoc(); 

What is the differ

4条回答
  •  一整个雨季
    2020-12-03 05:58

    fetch_array will give you key/value pairs and with indexes, where as fetch_assoc will give you only the key/value pairs but not with indexes. For example:

    //fetch_array output be like:
    [name]=>'someName'
    [0]=>'someName'
    [email]=>'some@some.com'
    [1]=>'some@some.com'
    
    //fetch_assoc output be like
    
    [name]=>'someName'
    [email]=>'some@some.com'
    

提交回复
热议问题