• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert a single column of values into a comma seperated list


A PHP Error was encountered

Severity: Warning

Message: file(/Applications/MAMP/tmp/php/phptbY3qH) [function.file]: failed to open stream: No such file or directory

Filename: controllers/start.php

Line Number: 94
A PHP Error was encountered

Severity: Warning

Message: implode() [function.implode]: Invalid arguments passed

Filename: controllers/start.php

Line Number: 95


so you need the full path to the temp file in php 5.2 you can get it using the sys_get_temp_dir function, if you have an older version you can use this user submitted function
if ( !function_exists('sys_get_temp_dir')) {
  function sys_get_temp_dir() {
    if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
    if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
    if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
    if (file_exists($tempfile)) {
    return realpath(dirname($tempfile));


I believe i have solved the problem. I borrowed a bit of code from the comments on fgetcsv on php.net and we now have:
$temp_csv = $_FILES['userfile']['tmp_name'];
                $content = file_get_contents($temp_csv);

                $ret = ereg_replace(chr(13) . chr(10),",",$content);
                $ret = ereg_replace(chr(13),",",$ret);
                //$str = explode("\n", $ret);
                echo $ret;

Which works on windoze and mac.

Thanks for all your help today, you've been great.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.