Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Php string to array
Php string to array
You can use str_split to convert a string into an array. The usage of str_split is as follows:

Str _ split— Converts a string into an array.

Array? str_split(? String? $string? [,? int? $split_length? =? 1]? ) String: Enter a string.

Split_length: the length of each segment.

Return value

If the optional split_length parameter is specified, each element in the returned array is a character block with the length split_length; Otherwise, each character block is a single character. ?

Returns FALSE if split_length is less than 1. If the split_length parameter exceeds the string and exceeds the length of the string, the entire string will be returned as the only element of the array. ?

Use example:

$str? =? "hello? The world ";

$arr? =? str _ split($ str);

print _ r($ arr); The above code will be output.

rank

(

[0] = >H

[ 1] = >e

[2] = >l

[3] = >l

[4] = >o

[5] = >

[6] = >W

[7] = >o

[8] = >r

[9] = >l

[ 10] = >d

)