How to distinguish associative arrays from indexed arrays

php中世界最好的语言
Release: 2023-03-22 09:06:01
Original
2426 people have browsed it

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
Copy after login

Associative array:

 mysql_fetch_assoc()
 array([username]=>'test',[password]=>'123456')
Copy after login

Index array:

mysql_fetch_array()
array([0]=>'test',[1]=>'123456')
Copy after login

var_export()

array ( 0 => 1, 1 => 'a', 2 => 'hello', )
Copy after login

var_dump()

array(3) { [0]=> int(1) [1]=> string(1) "a" [2]=> string(5) "hello" }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template