In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article Xiaobian for you to introduce in detail "the array keys in php are determined as numbers", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "array keys in php is determined to be numbers?" this article can help you solve your doubts.
In php, the array key does not have to be a number, it can also be a string. PHP arrays are flexible, supporting not only indexed arrays with integer keys, but also associative arrays with strings or mixed strings and numbers as key names; if the array key name is a string, add a delimiter (single quotation mark''or double quotation mark "") to the key name.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, the array key does not have to be a number, it can also be a string.
The array array is an ordered set of variables, where each value is called an element. Each element is distinguished by a special identifier called a key (also known as a subscript).
Each entity in the array contains two items, a key (key) and a value (value). The corresponding array elements can be obtained by key values, which can be numeric keys or associated keys. If a variable is a container for a single value, then an array is a container for multiple values.
PHP arrays are more flexible than arrays in other high-level languages, supporting not only indexed arrays with numbers as key names, but also associative arrays with strings or strings and mixed numbers as key names.
1) indexed array-numeric key name
The subscript (key name) of an indexed array consists of numbers. By default, starting from 0, each number corresponds to the position of an array element in the array, which does not need to be specified. PHP automatically assigns an integer value to the key name of the indexed array, and then increments automatically from this value. As follows:
$arr=array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
2) associative array-- string key name
The subscript (key name) of an associative array consists of a mixture of numeric values and strings, and if an array has a key name that is not a number, then the array is an associative array. As follows:
Arr=array ("id" = > 1, "name" = > "Li Hua", "age" = > 23, "1" = > 1, "id2" = > 52)
Description: the key name of an associative array can be any integer or string. If the key name is a string, add a delimiter to the key name-single quotation mark''or double quotation mark "". For indexed arrays, to avoid confusion, it is best to add delimiters as well.
After reading this, the article "is the array key in php set as a number" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.