Jump to content

Cannot crack this..


glenelkins

Recommended Posts

Im writing a script that should be simple but its becoming a pain. It reads a CSV file line by line, then splits the lines into an array (seperated by commas)

Here is the code
[code]
<?
/* CSV to MYSQL conversion utitliy */
/* Author: Glen Elkins */
/* 08/2006 */

// Set variables
define ("APP_PATH",".");
define ("CSV_FOLDER","/csv/");
define ("CSV_FILE","contacts.csv");

// Open The File
$csv_data = file(APP_PATH.CSV_FOLDER.CSV_FILE);

// Just read the first line to test
            echo $csv_data[0];  -  displays the first line: uid,email,valid,optin,source

            $line = $csv_data[0];
$exploded = explode("&#44;",$line);

echo $exploded[0]; - should display uid but displays uid,email,valid,optin,source

?>
[/code]

Can anyone see the problem?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.