After a bit of hunting around for a solution. I thought it was time to ask the brains trust here on stackoverflow.
I'm looking for a way to take a list, in the form of a string, split it using commas and insert into columns in a mySQL table.
The list would be something like:
- Tim Moltzen, 2. Joel Reddy, 3. Blake Ayshford, 4. Chris Lawrence, 5. James Tedesco, 6. Benji Marshall, 7. Braith Anasta, 8. Aaron Woods, 9. Robbie Farah, 10. Jack Buchanan, 11. Bodene Thompson, 12. Liam Fulton, 13. Adam Blair, 14. Ben Murdoch Masila, 15. Ava Seumanufagai 16. Matt Bell, 17. Eddy Pettybourne
From that list, two things are needed to be split. The number and the name.
So, the number would be inserted into the "player_number" column and the name into "player_name". Of course the commas are only used for spacing, and don't need to be interested into the table.
Any assistance on how to split the string and then insert into the table would be extremely appreciated.
EDIT::
I'll see what I can work with using explode and running a loop to insert them into the table.
explode()to split by comma into an array. Then create a PDO prepared statement for inserting one row. Useforeach()to loop through the array and insert to DB using your prepared statement.preg_match();to get your numbers, add them to an array using something like/([0-9]\.)\s+([a-zA-Z\])/you should be able to get the numbers and values. also you might have to use theexplode()function.