DanH42 Posted July 9, 2010 Share Posted July 9, 2010 I'm just learning how to do arrays in php, but I'm pretty sure this can be done.I've got a comma-separated text file that will contain a bunch of data. I want the data to be put into an array so it can be easily retrieved. So, I would end up with an array looking like this: Array( [John Smith] => Array ( [status] => Array ( [0] => 'Test message' ) [pictures] => Array ( [0] => 'beach.jpg' [1] => 'birthday_01.png' [2] => 'birthday_02.png' ) ) [steve Doe] => Array ( [status] => Array ( [0] => 'Message 1' [1] => 'Another message'] ) )) How would I turn a CSV into something like that? Link to comment Share on other sites More sharing options...
boen_robot Posted July 10, 2010 Share Posted July 10, 2010 Assuming you have PHP 5.3 and above, you can use str_getcsv(). I'm not sure if it generates the array in the exact fashion you want, but it should be something similar. The comments on that function suggest alternatives in case you have an older PHP version. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.