PHP str_split Function Explained

The str_split() function in PHP is used to split a string into individual characters or substrings of a specified length. It is used to divide a string into an array of characters or substrings of a specific length.

Here is the syntax of the str_split() function:

str_split(string $string, int $split_length = 1): array

Among them:

  1. $string is the source string to be split;
  2. $split_length is an optional parameter that specifies the length of each substring, with a default value of 1.

For example, when calling a function like str_split(“Hello”, 2), it will return an array containing [“He”, “ll”, “o”], where each substring is a substring of length 2.

bannerAds