CLI PHP
Monday, June 30th, 2008It’s been a while since I last wrote a command line PHP script, but I needed one today to parse through a database dump csv file. This is how to get the ID, which was my first column:
if($file= file_get_contents(’myfile.csv’)) {
$line = split(”\n”,$file);
foreach($line as $lines) {
$data = split(”;”, $lines);
echo $data[0] . “\n”;
}
} else {
echo “couldn’t open”;
}