X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP str_split() Function

PHP String Reference PHP String Reference

Example

Split the string "Hello" into an array:

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

Run example »

Definition and Usage

The str_split() function splits a string into an array.


Syntax

str_split(string,length)

Parameter Description
string Required. Specifies the string to split
length Optional. Specifies the length of each array element. Default is 1

Technical Details

Return Value: If length is less than 1, the str_split() function will return FALSE.  If length is larger than the length of string, the entire string will be returned as the only element of the array.
PHP Version: 5+


More Examples

Example 1

Using the length parameter:

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

Run example »


PHP String Reference PHP String Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook