• PHP Video Tutorials

PHP - Function Str Split



Syntax

array str_split ( string $string [, int $split_length = 1 ] )

Definition and Usage

It is used to convert a string to an array

Return Values

If length is less than 1 than it returns false or else the entire string will be returned

Parameters

Sr.No Parameters & Description
1

string

It contains the information about input string

2

length

It contains the information about length of each array

Example

Try out the following example

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

This will produce following result −

Array ( [0] =>t [1] =>u [2] =>t [3] =>o [4] =>r [5] =>i [6] =>a [7] =>l [8] =>s [9] =>p [10] =>o [11] =>i [12] =>n [13] =>t )
php_function_reference.htm
Advertisements