Print This Page


csv_split ()

function csv_split ($line, $delim=',', $removeQuotes=true)

Convert CSV lines to an array. PHP already has a function to load a CSV file to an array, but not from a string to an array.

This function is made by php[at] from

$line = the csv line to be split

$delim = the delimiter to split by

$removeQuotes = if this is false, the quotation marks won't be removed from the fields

Example 1

require './includes/user_init.php';

$string = 'name,address,city,age,last position';
print_r (csv_split ($string));

// output:
// Array ('name','address','city','age','last position');

Posted On: Aug-23-2010 @ 07:00am
Last Updated: Jan-01-1970 @ 07:00am

There is no comment. Why not be the first?

More Comments/Post Your Own

Powered by qEngine
Generated in 0.012 second | 15 queries