Php notes: use of the range () round () and list () functions of php. The range () function is a simple method to quickly create an array. an integer from low to high is used to fill the array. the function returns an array containing all integers within the range. the format is as follows: arrayra
1>
The range () function is a simple method to quickly create an array. an integer from low to high is used to fill the array. the function returns an array containing all integers in the next range. the format is as follows:
Array range (int low, int high [, int step])
Typical usage:
Example: create an array of 6 numbers (DICE) from 1 to 6)
$ Die = range (0, 6 );
Create an array of all double numbers from 0 to 30
$ Even = (, 2); // the step size is 2.
This function can be used not only as a number but also as a letter.
For example
$ Words = range ('A', 'z ');
An array containing all letters A to Z will be created. this can be used to generate the verification code function.
II>
Round () function
I am afraid that this function will be confused. This function is quite different from the range () above.
This function is used
Precision of floating point number
Float round (float var [, int preisin })
Typical usage
Example: $ pi = 3.141592653;
Round ($ pi, 4 );
Echo $ pi;
Will output 3.1415
3>
List () function
The list () function can extract multiple values from a group in one operation. assign values to the variable at the same time. The form is as follows:
Void list (mixed)
Typical usage
The code is 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 above example is taken from the PHP Manual You can use list () and regular expressions to cut strings and store them in the variable table. Typical usage List ($ name, $ occupation, $ color) = exolode ("|", $ line );
The wide range () function is a simple method to quickly create an array. it fills the array with an integer from low to high. the function returns an array containing all integers within the range. the format is as follows array ra...