Date: Source: GBin1.com have you checked all the PHP methods? I have made a rough statistical analysis. There are a total of 5025 PHP reference methods. If you are a beginner in this web programming language, I will introduce several very practical PHP methods, hoping to help you! Function1: array_rand first we will introduce this simple method array
Date: Source: GBin1.com have you checked all the PHP methods? I have made a rough statistical analysis. There are a total of 5025 PHP reference methods. If you are a beginner in this web programming language, I will introduce several very practical PHP methods, hoping to help you! Function1: array_rand first we will introduce this simple method array
Date: 2012-7-26 Source: GBin1.com
Have you checked all the PHP methods? I have made a rough statistics on 5025 PHP reference methods. If you are a beginner in this web programming language, I will introduce several very practical PHP methods, hoping to help you!
Function1: array_rand
First, we will introduce this simple method array_rand.
Do you want to randomly retrieve one from an array? You can use rand or mt_rand to get a random number. Pass 0 and the last index value as the minimum and maximum parameters of the array, this will give you a random key that you can use to obtain the value of the array.
Of course, there is a more convenient way to implement the above function: array_rand, you only need to pass an array, it will automatically return a random key to you. As follows:
$sites = ["gbin1.com", "gbtags.com", "baidu.com", "google.com"]; $k = array_rand($sites); $sites[$k];
If you need more than one random value, you can also pass the second parameter to set the number of returned values so that you can get a random array.
Function2: strip_tags
.........
Source: PHP tips: 7 practical PHP methods suitable for beginners