: This article mainly introduces the regular expression of PHP split and the php function explode. if you are interested in the PHP Tutorial, refer to it.
- Preg_split ($ pattern, $ subject)
Use $ pattern to match the string, use the matched string as the split point, split the subject into multiple strings, and put them into an array.
Explode (string $ delimiter, string $ string [, int $ limit])
The function returns an array composed of strings. each element is a substring of a string, which is separated by a string delimiter as a boundary point.
If the limit parameter is set and it is a positive number, the returned array contains up to limit elements, and the last element contains the rest of the string.
If the limit parameter is negative, all elements except the last-limit element are returned.
If the limit value is 0, it is regarded as 1.
This function returns an array composed of strings. each element is a substring of a string, which is separated by a string delimiter as a boundary point.
If delimiter is a null string (""), explode () returns FALSE. If delimiter contains a value that cannot be found in string and uses a negative limit value, an empty array is returned. Otherwise, an array containing a single string element is returned.
// Example 1 $ pizza = "piece1 piece2 piece32 piece42 piece5 piece6"; $ pieces = explode ("2", $ pizza,-1); echo'
'; Echo $ pieces [0]; // piece1echo $ pieces [1]; // piece2echo'
'; Show ($ pieces); echo'
'; // Example 2 $ data = "foo: *: 1023: 1000:/home/foo:/bin/sh"; list ($ user, $ pass, $ uid, $ gid, $ gecos, $ home, $ shell) = explode (":", $ data); echo $ user; // fooecho $ pass; // * echo'
';
'). 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 section describes the regular expression in PHP, the split and the php function explode, including some content, hope to be helpful to friends who are interested in the PHP Tutorial.