Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does php ergodic array mean?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces what the php ergodic array refers to, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Php traversal array means that every element in the array is accessed through php code, the method of traversing the array: 1, traversing the array through for loop; 2, traversing the array through foreach loop, and so on.

This article operating environment: Windows7 system, PHP7.4 version, DELL G3 computer

Php traversing an array means accessing every element in the array through php code.

Array creation:

1.array (): generate an array

$a=array ("Dog", "Cat", "Horse"); print_r ($a)

Array value or, key = > value an array variable

Strongly typed language: 1. Only data of the same data type can be stored in the array. Array 2 is fixed in length and 3 is continuous in memory.

two。 Associative array: $arr=array ("111l" = > "ddd", "daf" = > "ddd")

Key and values exist in pairs

3.unset () deletes array elements

$a=array ("Dog", "Cat", "Horse"); unset ($a [0])

4. Add elements:

$a [0] = 10; add elements

$a [] = 10; append elements

Array_push ($a dint 23); append elements

Traverse the array:

1.for ($itemo / sectionk) {echo $v. "-". "$k". "

";}

Key and value traversal at the same time

3.list () and each () combine traversal

Var_dump (each ($a)); take out the element that the current pointer points to, return to a new array and adjust the pointer back to one

List ($bmeme) = $a _ bot echo $b

Give the array on the right to a set of variables

List ($KJV) = each ($a); while (list (KJV) = each ($a)) {echo $k. "-". "$v". "

"}

4 array pointer operation:

Key (): returns the key name that the inner pointer of the array currently points to the element

Current (): returns the current element (unit) in the array.

Next (): moves the pointer to the current element to the position of the next element and returns the value of the current element

Prev (): moves the pointer to the current element to the position of the previous element and returns the value of the current element

End (): points the inner pointer of the array to the last element and returns the value of that element

Reset (): points the inner pointer of the array to the first element and returns the value of that element

Do {current ($a)} while (next ($a))

Execute first and then judge conditions

In_array () determines whether the element appears in the array array_reverse () flips the non-prime number of the count () array array_unique () deletes the duplicate value in the array and returns a new array; unset () deletes a value of the array _ values () to re-index the array_merge () merge array

Thank you for reading this article carefully. I hope the article "what is the meaning of php ergodic array" shared by the editor will be helpful to you? at the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report