PHP tips: 7 practical PHP methods suitable for beginners

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.