A reference to a foreach$arr = Range (1,3//foreach as &foreach as $val) {} print_r ($arr);What does the above code output?Array ( [01 [12 [22 )This is because of the reference to the variable in the source of the foreach. Causes its
Compare the efficiency of strtr, str_replace, and preg_replace functions. The source code of strtr has been analyzed before, and the efficiency of strtr, str_replace and preg_replace is compared Now: The copy code is as follows: $ str1111111111111_1_
The source code of strtr has been analyzed before. Now we can compare the efficiency of strtr, str_replace and preg_replace:
Copy codeThe Code is as follows: $ str =
'2017
';
$ Str = str_repeat ($ str, 1 );
$ Pattern1 = array ('000000' => '', '000000
Test 1
1, less operation elements, a single element is larger, English, 3 elements to operate 1000 times
The code is as follows
Copy Code
$data = Array (' Hello ', ' word ');$d = "Helloword";$d = Str_repeat ($d,
This article provides a detailed analysis of the efficiency of strtr, str_replace, and preg_replace functions. For more information, see the source code of strtr, now we can compare the efficiency of strtr, str_replace and preg_replace:
The code
This article provides a detailed analysis of the efficiency of strtr, str_replace, and preg_replace functions. For more information, see
This article provides a detailed analysis of the efficiency of strtr, str_replace, and preg_replace functions.
Have analyzed the source of strtr before, now compare Strtr, str_replace and preg_replace efficiency:
Copy CodeThe code is as follows:
$str =
' 111111110000000000000000000000000000000111000001000100010000010010000010010000010100000010
';
$str = Str_
Var_dump ()
void Var_dump (mixed expression [, mixed expression [, ...]])
The Var_dump () method is to determine the type and length of a variable and output the value of the variable if the variable has a value that is the value of the variable
Hey, this is the only problem left !!! 7. compile a program using a custom function to calculate the running time of the page script. Please use the PHP language !!!
Reply to discussion (solution)
Custom write? Functions are available.
function
Objective
The following is the implementation of the classic algorithm through PHP, and calculate the time-consuming, can be time-consuming comparison of the complexity of these algorithms.
Insert Sort
Bubble sort
Select sort
and
Str_replace can find replacement regular characters,Preg_replace to find replacement carriage return newline characters (\ r \ n)Preg_replace is commonly used in
The code is as follows
Copy Code
getdescription)))?> ">
In general, if We cache the array into a file, we need to convert it into a string first, and then store it in a text file. Generally, there are two mechanisms to convert the array into a string, the first is $ strvar_export ($ arr, true); the
In general, if we cache the array into a file, we need to convert it into a string first, and then store it in a text file. Generally, there are two mechanisms to convert the array into a string,
In general, if we cache the array into a file, we
7, the use of custom functions to write programs to calculate the running time of the page script. Please use PHP language!!!
Reply to discussion (solution)
Custom write? There's a function available, a blind toss.
function speed () { static
This function has been used for obtaining:Copy codeThe Code is as follows:Function microtime_float (){List ($ usec, $ sec) = explode ("", microtime ());Return (float) $ usec + (float) $ sec );} We can see that microtime (true) is used in other
This function has been used for obtaining:
CopyCode The Code is as follows: function microtime_float (){
List ($ USEC, $ Sec) = explode ("", microtime ());
Return (float) $ USEC + (float) $ Sec );
}
We can see that microtime (true) is used in
Phpmicrotime gets the floating point timestamp. This function has been used for obtaining: Copy the code as follows: functionmicrotime_float () {list ($ usec, $ sec) explode (, microtime (); return (float) $ usec + (float) $ sec);} you can see that
Detailed description of var_dump () function in php. This article provides a comprehensive introduction to the usage of var_dump () functions in php. For more information, see. Var_dump () voidvar_dump (mixedexpression [, mixedexpression [,...])
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.