How can I split a delimited string into an array in PHP?
Try explode:
$myString = "9,[email protected],8";
$myArray = explode(',', $myString);
print_r($myArray);
Output :
Array
(
[0] => 9
[1] => [email protected]
[2] => 8
)
$myString = "9,[email protected],8";
$myArray = explode(',', $myString);
foreach($myArray as $my_Array){
echo $my_Array.'<br>';
}
Output
9
[email protected]
8
$string = '9,[email protected],8';
$array = explode(',', $string);
For more complicated situations, you may need to use preg_split
.