mysql - PHP - List pulled from one field exploding commas
The title may be a bit misleading, to be honest I don't know what this feature is called.
I have a field which will contain a list of a users skills in the database, the skills will be separated by commas.
When I then echo the field, I want each skill after the commas to be in a new list element.
So it'll echo like this in the HTML:
<ul>
<li>Cycling</li>
<li>Driving</li>
<li>Running</li>
</ul>
However in the field 'skills' it'll look like:
Cycling, Driving, Running
I read that you need to explode the comma however I have no idea how to accomplish it.
Answer
Solution:
Here's explode:
Filter to trim the values of the array (so there's no whitespace on them) using array_map:
Then glue it back up with implode:
Put it all together, with a bit of defensive programming:
Answer
Solution:
You could use :
Answer
Solution:
This can be achieved with
explode
(php documentation).Answer
Solution:
Answer
Solution:
I've got it working now! :)
Thanks to who contributed.
Code I used: