Usage example of the str_split function specified by php, which is a string str_split
This example describes the usage of the str_split function, which is a string specified by php. We will share this with you for your reference. The details are as follows:
Example 1:
$ Str = 'abcdefgh'; $ arr = str_split ($ str, 2 );
The running result is as follows:
Array (4) {[0] => string (2) "AB" [1] => string (2) "cd" [2] => string (2) "ef" [3] => string (2) "gh "}
Example 2:
$ Str = 'abcdefgh'; $ arr = str_split ($ str); $ I = 0; $ limit = 3; $ num = count ($ arr ); while ($ I <= $ num-1) {$ temp = array (); $ for_countbu = ($ num-$ I) >=$ limit? $ Limit: $ num-$ I; for ($ j = 0; $ j <$ for_countbu; ++ $ j) {$ temp [] = $ arr [$ I]; + + $ I ;}$ one = implode ('', $ temp); $ result [] = $ one;} print_r ($ result );
The running result is as follows:
Array (4) {[0] => string (2) "AB" [1] => string (2) "cd" [2] => string (2) "ef" [3] => string (2) "gh "}