Bladephp: Now with 7+ codeigniter, php, and laravel project 7+ php project From $18/Year From Rs. 1000/Year

PHP explode() Function

by
Category:php
php php function
PHP explode() Function

The explode() function breaks a string into an array.

Note: The "separator" parameter cannot be an empty string.

The explode() function space string into an array.

The explode() function comma separated a string into an array.

$string = "9,8,7,abc";
$array = explode(',', $string);
print_r($array);

Output

Array
(
    [0] => 9
    [1] => 8
    [2] => 7
    [3] => abc
)

Another Example

$string = "9 8 7 abc";
$array = explode(' ', $string);
print_r($array);

Output

Array
(
    [0] => 9
    [1] => 8
    [2] => 7
    [3] => abc
)

0 Comments


Html code work in comment box


Related Post