Home >> PHP >> how to split string into array in PHP

how to split string into array in PHP

Split a string and returns an array.

Syntax

explode(separator,string);

Example

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

Output

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

Post Your Comment

Next Questions
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
What are the rules for naming a variable
How can you compare objects

Copyright ©2022 coderraj.com. All Rights Reserved.