Home > Article > Backend Development > How to distinguish associative arrays from indexed arrays
This time I will bring you the method of distinguishing associative arrays and index arrays. What are the precautions for distinguishing associative arrays and index arrays? Here are practical cases, let’s take a look.
Data
username password test 123456
Associative array:
mysql_fetch_assoc() array([username]=>'test',[password]=>'123456')
Index array:
mysql_fetch_array() array([0]=>'test',[1]=>'123456')
var_export()
array ( 0 => 1, 1 => 'a', 2 => 'hello', )
var_dump()
array(3) { [0]=> int(1) [1]=> string(1) "a" [2]=> string(5) "hello" }
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to use PHP’s recursive function
Data crawling of Tmall and Taobao products
The above is the detailed content of How to distinguish associative arrays from indexed arrays. For more information, please follow other related articles on the PHP Chinese website!