print

csv_split ()

You are here: C97net5.02 Database Functions

Convert CSV lines to an array

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]dogpoop.cjb.net from php.net.

$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

<?php
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 at 07:00am
Last Updated: Jan-01-1970 at 07:00am

There is no comment. Why not be the first?

read more More Comments/Post Your Own

Account

Search

Tags

acp add all also any create default display don download easy echo etc features field file files folder form function includes information init kemana link list may module name need number own page php please qengine read require script set site skin time tpl url use user using version welcome