In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
PHP array basic concepts are introduced in detail, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Arrays are very important in our PHP, how to use arrays to achieve the functions we want, let's take a look at the basics of PHP arrays. Our learning time is not long, but some members can not wait to achieve a lot of website functions, ha ha, it is very good to have such requirements and wishes, this is actually the driving force of our progress. However, as a programming language, we still have to master some basic rules, such as data types, syntax and so on.
Fortunately, PHP is not difficult, and there are not many of these things. If we learn a few more lessons, we can begin to use it to achieve a website function. At that time, I believe you will be more and more energetic. Okay, let's start today's lesson. Today we learn about arrays. Arrays are a data type, and they are used very frequently. Learning to deal with arrays will make it easy for you to do websites. For example: you have large articles in your website database, and now you want to display 20 entertainment news headlines on one page. Do you want to use 20 variables when these 20 headlines are taken out of the database? I don't think you are so stupid, so what variable can be used to fully receive these 20 pieces of data? Array variables are used for this.
What is an array? An array is actually a collection of data, which is equivalent to a data container. A lot of data is stored in it, and we can store or take it out in a certain way, and we can sort the data in it. We can also check whether there is any data we want and so on.
Definition of the PHP array:
You can create a new array (array) using the array () language structure. It accepts a certain number of key = > value parameter pairs separated by commas. For example, 8-1:
The data in the array is actually arranged in a certain order, each data has a key corresponding, the key (key value) is determined by yourself, if you do not give a key, the system will assign a key value (key) according to the sequence. We do not give a key value for "Yahoo" here, but the system will assign it a key value of 4.
Since the system can automatically assign key values, is it possible not to write key values? Of course, for example, you can write 8-2:
Note here: the system assignment key value (key) starts from 0. Do you know what the key value of "Sina" is?
How to access PHP array data:
So much of the data above is represented by the variable $arr. What should we do to extract the data we want from it? For example, take the data from 8-1 cases and do this 8-3:
Is to use the variable name plus different key in square brackets to access different data. The key in square brackets is also called subscript. What should I do to get Sina in 8-2? By the way, use $arr [0].
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.