In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
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 the use of PHP array, the article is very detailed, has a certain reference value, interested friends must read it!
With the development of the times, we have more and more programming techniques. We must all know PHP very well. Let's introduce the PHP array here. PHP array is the most common bulk data storage structure. Because the array is stored sequentially, it can be stored randomly. In many languages, arrays are static, and you have to specify the length of the array before using it, but in PHP, you don't have to worry about it at all, the array is completely dynamic. You can even use an array like this.
PHP CODE / / DEMO of Array demo_array [] = 1; demo_array [] = 2
Let's use the PHP array to simulate the reshuffle of mahjong, a sport loved by the vast number of working people in China. Here first popularize the rules of mahjong, which are useful when serving MM's mother in the future. First of all, mahjong is for four people, and the 3p is not allowed. A total of 108 cards, 14 after touching the cards, 13 for each of the other 3, leaving 55. (there are N ways to play mahjong all over the country. Here we are talking about the way Easy plays in his hometown. There is no white card in the middle, which is the simplest game Easy has ever seen. Then let's analyze how to simulate this process with random numbers, which can be done more often, because extracting mathematical models from specific cases is the basic skill of programming. First of all, we use an array of 108 in length to store the 108 cards, and initialize them on the assumption that they are arranged sequentially.
Then, we will simulate the process of shuffling, which is actually the process of exchanging two cards several times. We can generate two random numbers between 1 and 108, and then exchange the values of the array elements with these two numbers as index. Because we have to exchange multiple times, we can define this process as a function. Then, the cards are divided into four people. In fact, as long as the number of exchanges in front of them is large enough, they will be cut directly into five OK. However, in order to better simulate the reality and represent the characteristics of the array, we use a circular way to distribute. That is, each person has four at a time, then one for each person, and two for the banker. All right, that's the whole process. Below we will explain some more detailed things through the program.
PHP CODE above is all the content of the article "what's the use of PHP arrays?" Thank you for reading! Hope to share the content to help you, more related knowledge, 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.