Home >> PHP >> string to array in PHP

string to array in PHP

explode() function used for Split a string and returns an array.

Syntax

explode(separator,string);

Example

$string="Hello Dear";
$explode=explode(" ",$string);
print_r($explode);

Output

Array(
    [0]=>Hello
    [1]=>Dear
)

Post Your Comment

Next Questions
array to string
how to split string into array
How to convert array to string
Difference between exit and die
Set Cookie
Access Cookie
Remove Cookie
how to remove \r\n from string
how to remove new lines from string
how to remove nbsp from string
How to remove all whitespace from a string
How to convert array to string separated by comma
How to list last 12 months from current month
Get the last 12 months from current month
How to list last 6 months from current month
Get the last 6 months from current month
How to list last 12 months from current month by loop
Get the last 12 months from current month by loop
How to list last 6 months from current month by loop
Get the last 6 months from current month by loop
Differentiate between variables and constants
How to increase maximum execution time
How to Increase File Upload Size
Set maximum execution time
Set maximum execution time unlimited

Copyright ©2022 coderraj.com. All Rights Reserved.