The substr_compare () function compares two strings from the specified start length.This function returns:0-if the two strings are equal> 0-if string1 (starting position) is greater than string2SyntaxSubstr_compare (string1, string2, startpos,
The similar_text () function calculates the number of matching characters for two strings.This function can also calculate the similarity between two strings (expressed in percentages ).SyntaxSimilar_text (string1, string2, percent)Note: The
$ Email = 'User @ example.com '; // defines the string$ Result = strstr ($ email, '@'); // returns a substring.Echo $ result;/*The strstr () function searches for the first occurrence of a string in another string.This function returns the rest of
// The parameter 'A. Z' defines that all uppercase and lowercase letters are escaped.Echo addcslashes ('foo [] ', 'A. Z'); // output: foo []//$ Str = "is your name o 'Reilly? "; // Define a string, including characters to be escapedEcho addslashes ($
*/$ Array = array ("size" => "xl", "color" => "gold"); // defines an arrayPrint_r (array_values ($ array); // outputs all values of the array./*Definition and usageThe array_values () function returns an array containing all the key values in the
$ Array = array ('step one', 'step two', 'step three ', 'step four'); // defines an arrayEcho current ($ array). " n"; // returns the first element of the array.Next ($ array); // The array pointer moves one bit behindNext ($ array); // The array
//$ Array = array (, =>, 3 => 13); // create an arrayPrint_r ($ array); // outputs the array content//$ A = array ('green', 'red', 'yellow'); // defines the first array.$ B = array ('avcado', 'apple', 'bana'); // defines the second array.$ C = array_
Let's take a look at the complete deletion of duplicate array instances. The code is as follows:Copy code // Delete an element from the arrayFunction array_remove_value (& $ arr, $ var ){Foreach ($ arr as $ key => $ value ){If (is_array ($ value
Php strlen () functionDefinition and usageThe strlen () function returns the length of the string.SyntaxStrlen (string) parameter descriptionString is required. Specifies the string to be checked. The code is as follows:Copy code Echo strlen
A few days ago, I asked the oso forum if there was any source code and no one replied. Finally, I made up my mind to transplant such a function and thanked the netizen Keyes for providing the Delphi source code for transplantation. The call method
Some useful functions can be saved as source code, and you can avoid writing them again later.File read function// File read functionFunction PHP_Read ($ file_name ){$ Fd = fopen ($ file_name, r );While ($ bufline = fgets ($ fd, 4096 )){$ Buf. = $
* Implement a function. Input a piece of text and parse the text into an array. The key of each element in the array line is specified by the input parameter.Function prototype: function ExplodeLines ($ text, $ columnNames)For example, enter: The
Use pathinfo functions The code is as follows:Copy code Function extend_2 ($ file_name){$ Extend = pathinfo ($ file_name );$ Extend = strtolower ($ extend ["extension"]);Return $ extend;} Definition and usageThe pathinfo () function returns the
The code is as follows:Copy code $ Route-> run ();/*** Execute the corresponding MCA **/Private function run () {$ FilePath = APPLICATION_PATH. '/controller/'. $ this-> _ moudle. '/'. $ this-> _ conttoller. '. inc. Php ';$ IsNo =
Foreach statementThe Foreach loop is introduced in php4.0 and can only be used as an array. In php5, object support is added. The syntax format of this statement is:Foreach (array_expression as $ value)Statement;Or The code is as follows:Copy code
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