note 59912 added to function.popen

From: Date: Tue, 20 Dec 2005 00:28:58 +0000
Subject: note 59912 added to function.popen
Groups: php.notes 
Request: Send a blank email to php-notes+get-100440@lists.php.net to get a copy of this message
// The above import function can be easily extended using // /usr/local/bin/xls2csv (part of catdoc ) and popen // to read excell files directly. // In our particular application the first line was the file heading. function importxls($file,$head=true,$throwfirst=true,$delim=",",$len=1000) { $return = false; $handle = popen("/usr/local/bin/xls2csv $file", "r"); // or die if not there. if ($throwfirst) { $throw = fgetcsv($handle, $len, $delim); } if ($head) { $header = fgetcsv($handle, $len, $delim); } while (($data = fgetcsv($handle, $len, $delim)) !== FALSE) { if ($head AND isset($header)) { foreach ($header as $key=>$heading) { $row[$heading]=(isset($data[$key])) ? $data[$key] : ''; print "<li>". $heading ."=>" . $row[$heading]."</li>"; } $return[]=$row; } else { $return[]=$data; } } fclose($handle); return $return; } ---- Manual Page -- http://www.php.net/manual/en/function.popen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59912 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59912&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59912&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59912&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59912&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59912&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59912&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59912&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59912&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100440) next »