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

How to php as long as the value of the array does not have a key

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to php as long as the values of the array do not have keys". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Php as long as array values without keys: 1, create a PHP sample file; 2, define an array; 3, through "while ($fruit = current ($fruits)) {.]" Method to get the value of the array without a key.

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

Why does php only need the values of the array without keys?

Gets the current array value current ()

The current () function returns the array value of the position of the current pointer in the array. It takes the following form:

Mixed current (array array)

Let's modify the previous example, this time we want to get the array values:

$fruits = array ("apple" = > "red", "banana" = > "yellow"); while ($fruit = current ($fruits)) {printf ("% s", $fruit); next ($fruits);} / / red / / yellow

Related introduction:

The current () function returns the value of the current element in the array.

Each array has an internal pointer to its "current" element, initially to the first element inserted into the array.

Tip: this function does not move the internal pointer of the array.

Related methods:

End ()-points the internal pointer to the last element in the array and outputs it.

Next ()-points the internal pointer to the next element in the array and outputs it.

Prev ()-points the internal pointer to the last element in the array and outputs it.

Reset ()-points the internal pointer to the first element in the array and outputs it.

Each ()-returns the key name and key value of the current element and moves the internal pointer forward.

This is the end of the content of "how to php as long as the values of the array do not have keys". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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