: This article mainly introduces PHP ---- String. if you are interested in the PHP Tutorial, you can refer to it.
Var_dump (explode (":", "php: 123"); // The Returned array is split. Output: php, 123 echo implode (',', array ('A', 'B'); // return string output: a blist ($ user, $ pass) = explode (":", "php: 123"); echo $ user, $ pass; // return string output: php123 $ array = array ('php ', '20140901'); echo join (",", $ array); // return string output: php, 123 strrchr ('abab', 'A '); // AB (last occurrence) substr ('abcd', 1); // bcd (return string substring) substr ('abcd ); // cdsubstr ('abcd',-); // d (extract digits by length) substr ('abcd ); // cdstrpos ('abcd @ yahoo.com ',' @ '); // 4 (positioning character) substr ('abcd @ yahoo.com', 0, strpos ('abcd @ yahoo.com ', '@'); // abcdstr_repeat ('A', 5); // aaaaa (repeat a string) str_shuffle ('ABCD'); // cbda note: stripos ('abca', 'A'); // 0 (note: a is on the first position, find the first occurrence location of a string (case insensitive) strripos ('abca', 'A '); // 3 (calculate the position of the last occurrence of the specified string in the target string (case insensitive) strrpos ('abca', 'A '); // 0 (calculate the position of the last occurrence of the specified string in the target string) substr_count ('abcd', 'B'); // 1 (calculate the number of occurrences of the string) strcspn ('aabb CC', 'C'); // 5 (returns the number of characters searched in the string before any specified character is found) strspn ('abcdef ', 'ABC'); // 3 (returns the number of characters contained in the string) strspns ('abcdef', 'BC'); // 0 strspns ('abcdef ', 'BC',); // 2chr (65); // A (get ASCII code) ord ('A'); // 65 strchr ('AA BB ', 'A'); // a bb (returns a specified string) strchr ('AA BB', 99); // null note: ASCII c: 99 strchr ('AA bb ', 97); // a bb note: ASCII a: 97 addcslashes ('aab', 'A '); // \ a \ abb (the function adds a backslash before a specified character) addslashes ("aa bb"); // aa bb \ '(escape: predefined ', \) lcfirst ('Hello World'); // Hello World (the first character is lowercase) ltrim (": php: 123:", ':'); // php: 123 (remove the left and right characters) rtrim (": php: 123:", ':'); //: php: 123 (remove the right character) trim (": php: 123: ", ':'); // php: 123 (remove the left character) nl2br (" php \ r \ n123 "); // php
123 (Insert Row label) wordwrap ('aaabbb', 3 ,'
', True); // aaa
Bbb (the interrupt string is a specified number of strings) quotemeta ('abcd. () '); // abcd \. \ (\) --- (reference metacharacters:. + *? [^] ($) Similar_text ('abcd', 'AAA', $ sim); // 25 (similarity between two strings) similar_text ('abcd ', 'AAA'); // 1 sprintf ('name: % s, age: % d', 'AAA', 12); // (returns a formatted string) str_ireplace ('A', '11', 'aa22'); // 1122 (case-insensitive version) strcasecmp ('hello', 'Hello'); // 0 note: left> right: positive; Reverse: negative (binary security comparison string (case insensitive) str_pad ('AAA', 10); // aaa (followed by 7 spaces) -- (use another string to fill the string with the specified length) str_pad ('AAA', 10, '-', STR_PAD_LEFT); // ------- aaa; str_pad ('AAA', 10, '-', STR_PAD_BOTH); // --- aaa ---- $ str = "hello1
"; Strip_tags ($ str); // hello1 (remove HTML and PHP tags from strings) strip_tags ($ str ,''); // Hello
1
Stripcslashes ('AA \ bb '); // aab (escape string remove backslash) stripcslashes ('AA \ bb '); // aa \ bbstripslashes ('this is \ 0 one'); // This is one (references a reference string) stristr ('ABC @ 163.com ',' B '); // Bc@163.com (case-insensitive version of the function) stristr ('ABC @ 163.com ',' B ', true); // Astrstr ('ABC @ 163.com ','@'); // @ 163.com( the first occurrence of a search string) strstr ('ABC @ 163.com ',' @ ', true); // ABcstrlen (' AB CD '); // 5 (get string length) strcmp ("aaa", "bbb"); //-1 Note: Comparison of binary security strings strncmp ('abcd', 'AB ', 2); // 0 Note: 2 matches 0, Part 1, without-1 strncmp ('abcd', 'A', 2 ); // 1 strncmp ('abcd', 'C', 2); //-1substr_compare ('abcd', 'B ); // 0 (binary security comparison string (compare the specified length from the offset) substr_compare ('abcd', 'C',-); // 0substr_compare ('abcd ', 'B', true); // 0substr_replace ('abcd E', '1', 5); // abcd 1 (replace the substring of a string) substr_replace ('abcd E', '1',-1); // abcd 1substr_replace ('abcd E', '1', 2, 2 ); // ab1 estr_replace ('A', 11, 'aa22'); // 1122 (substring replacement) strpbrk ('abac', 'A '); // Ac (search for any character of a group in a string) strpbrk ('abac', 'cb '); // bAc (search for any character of a group in a string) strrev ('ABCD'); // dcba (reverse string) strtok ('AA/bb ', '/'); // aa (Mark the split string) strtolower ('ABC'); // ABc (convert the string to lowercase) strtoupper ('ABC '); // ABC (converts a string to uppercase) ucfirst ('ABCD'); // abcd (converts the first letter of a string to uppercase) ucwords ('abcd CC '); // Abcd Cc (converts the first letter of each word in the string to uppercase) trtr ('abbcc ', 'AC', '11 '); // 11bb11 (removes the white spaces at the beginning and end of the string) $ arr = array ('Hello' => 'hi', 'World' => 'Today '); echo strtr ('Hello World', $ arr); // hi todaytrim ('ABCD'); // abcd (removes spaces at the beginning and end of the string) trim ('xabcdx ', 'X'); // abcdmd5_file ("C: \ d \ d.txt"); // md5 ("C: \ d \ d.txt") must exist in the d.txt file "); // double md5 encryption classTestMd5 {functionget ($ num) {$ num = md5 ($ num ). "En"); return $ num ;}$ testMd5 = new TestMd5 (); echo $ testMd5-> get ("test "); $ date = date ("Y-m-d H: I: s"); list ($ y, $ m, $ d, $ h, $ I, $ s) = split ('[-:]', $ date); echo "$ y year $ m month $ d Day $ h hour $ I minute $ s second "; // break down the string number_format (1234.56); // 1234.56 (formatted number) number_format (1234, 2, ',', ''); // 1234.56, 56number_format (, 2, '. ', ''); // 1 234.56 $ str = 'first = one & arr [] = a + B & arr [] = ccc'; parse_str ($ str ); // Parse the string variable $ first; // one $ arr [0]; // a B $ arr [1]; // ccc; parse_str ($ str, $ put ); $ put ['first']; // one $ put ['arr'] [0]; // a B $ put ['arr'] [1]; // ccc $ arr1 = array('img1.png', 'img10.png', 'img2.png '); sort ($ arr1); // natsort ($ arr1) by key value ); // Press the val value $ line = 'AA "bb cc. "dd.txt '; $ parsed = str_getcsv ($ line,'',' "'); // Parse the CSV string into an array var_dump ($ parsed); // array (3) {[0] => string (2) "aa" [1] => string (6) "bb cc. "[2] => string (6)" dd.txt "} print_r (str_split ('Hello World ')); // convert the string to the array print_r (str_split ('Hello World', 3 )); /* Array ([0] => h [1] => e [2] => l [3] => l [4] => o [5] => [6] => w [7] => o [8] => r [9] => l [10] => d) array ([0] => El [1] => lo [2] => wor [3] => ld )*/
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces PHP ---- String, including some content, and hope to be helpful to friends who are interested in PHP tutorials.