PHP function range () round () and list () How to use the _php tutorial

Source: Internet
Author: User
A >>

The range () function quickly creates an array of simple methods, populates the array with an integer value of low to high, and the function returns an array containing all the integers in the sub-range. The form is as follows

Array range (int low,int high[,int Step])

Typical usage is as follows

Example: Creating an array of 1-6 6 numbers (DICE)

$die = range (0,6);

Create 0-30 arrays of all even-numbered

$even = (0,20,2);//step is 2

This function can be used not only as a number, but also as a letter.

Such as

$words = Range (' A ', ' Z ');

An array of all the letters that contain a through Z is created. This can be used to generate Authenticode functions.

b >>

Round () function

This function is afraid to confuse me. This function is a huge difference from which range above.

The purpose of this function is to

The accuracy of the floating-point number

Float round (float var[,int preisin})

Typical usage

Example: $pi = 3.141592653;

Round ($PI, 4);

Echo $pi;

Will output 3.1415

Three >>

List () function

The list () function extracts multiple values from an array in a single operation. Assign a value to the variable at the same time. The form is as follows

void list (mixed)

Typical usage

Copy the code code as follows:

$info = Array (' coffee ', ' brown ', ' caffeine ');

Listing all the variables
List ($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it SPECIAL.N";

Listing some of them
List ($drink,, $power) = $info;
echo "$drink has $power. N";

Or Let's skip to only the third one
List (,, $power) = $info;
echo "I need $power!n";

?>
The example above is from the PHP manual, which can be used with the list () to cut strings into variable tables typical usage list ($name, $occupation, $color) = Exolode ("|", $line);

http://www.bkjia.com/PHPjc/371927.html www.bkjia.com true http://www.bkjia.com/PHPjc/371927.html techarticle a range () function is a simple way to quickly create an array, populating an array with an integer value of low to high, and the function returns an array that contains all the integers in the sub-range. Form the following array ra ...

  • 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.