Home  >  Article  >  Backend Development  >  What is the usage of str_split in php

What is the usage of str_split in php

WBOY
WBOYOriginal
2022-02-14 16:21:332928browse

In PHP, split is often used in the "str_split" function, which can split a string into an array. The usage is "str_split(string,length)"; when length is less than 1, this function will return false , when length is greater than the length of the string, the entire string is returned.

What is the usage of str_split in php

The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer

What is the usage of str_split in php

str_split() function splits a string into an array.

Syntax

str_split(string,length)

Parameter Description

string Required. Specifies the string to be split.

length Optional. Specifies the length of each array element. The default is 1.

Return value: If length is less than 1, the str_split() function will return FALSE. If length is greater than the length of the string, the entire string is returned as the only element of the array.

The example is as follows:

<?php
print_r(str_split("Hello"));
?>

Output result:

What is the usage of str_split in php

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the usage of str_split in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does ord mean in phpNext article:What does ord mean in php