Home >Backend Development >PHP Tutorial >How to distinguish associative arrays from indexed arrays

How to distinguish associative arrays from indexed arrays

php中世界最好的语言
php中世界最好的语言Original
2018-03-24 17:03:382441browse

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:

Post cannot obtain form data

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn