English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String Character String Functions Manual
The str_split() function is used to split strings and convert them to arrays
array str_split ( string $string [, int $split_length = 1 ] )
Used to convert string splitting to an array
If the optional split_length parameter is specified, each element of the array is a character block of length split_length, otherwise each character block is a single character.
If split_length is less than 1If the split_length parameter exceeds the length of the string, the entire string will be returned as the only element of the array.
Serial Number | Parameter and Description |
---|---|
1 | string Input String |
2 | length The length of each segment. |
Try the following example, split the string, note the difference between specifying the length and not specifying the length:
<?php //Split the string without specifying the split length 3codebox.com")); //Split the string, specify the split length of2 3codebox.com\2)); ?>Test and see‹/›
Output Result
Array ( [0] => n [1] => h [2] => o [3] => o [4] => o [5] => . [6] => c [7] => o [8] => m ) Array ( [0] => nh [1] => oo [2] => o. [3] => co [4] => m )