How do I turn a string into an array?
To do this you can use the explode function, like this, passing the delimiter to explode on as the first argument and the string as the second:
<?php
$mystring = "I,love,washing,up";
$myarray = explode(",",$mystring);
print_r($myarray);
?>
Which gives us this:
Array
(
[0] => I
[1] => love
[2] => washing
[3] => up
)
Comment on this Question and Answer >>>
ASK A QUESTION
More strings PHP Questions
If I have a string "$obj = new class()" how can I echo this in another file so that a class appears?How do I make sure a string is a certain length?
How do I count how many times each character occurs in a string?
How do I display newline characters on a webpage?
What is the difference between join and implode in PHP?
