PHP Notes: Php function range () round () and list () Instructions _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

复制代码 代码如下:

$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";

?>

上例摘自PHP手册 可以用list()配合正则来切割字符串存入变量表 典型用法 list($name,$occupation,$color) = exolode("|",$line);

http://www.bkjia.com/PHPjc/326968.html www.bkjia.com true http://www.bkjia.com/PHPjc/326968.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 ...

  • Related Article

    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.