By using explode() function we can convert string to array. explode() function is a in build php function. It used to convert
 string to array in php.

Example 1:

$str="Scott Tiger UK 24 Male";
$arr=explode(" ",$str);
print_r($arr);
Output:

Array
(
    [0] => Scott
    [1] => Tiger
    [2] => UK
    [3] => 24
    [4] => Male
)

Example 2:

$str="HTML,CSS,PHP,Javascript,Ajax";
$arr=explode(",",$str);
print_r($arr);

Output:

Array
(
    [0] => HTML
    [1] => CSS
    [2] => PHP
    [3] => Javascript
    [4] => Ajax
)

Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply