How to separate keywords and put them into an array on php which are written with a comma?
1 answer
Like this:
$pizza = "piece1, piece2, piece3, piece4, piece5, piece6"; $pieces = explode(",", $pizza); By adding the third line to the code (just to check the contents of the array)
print_r($pieces); We get the following conclusion
Array ( [0] => piece1 [1] => piece2 [2] => piece3 [3] => piece4 [4] => piece5 [5] => piece6 ) As required.
|