【发布时间】:2015-12-09 10:00:17
【问题描述】:
我创建了这个小脚本来解析一个 cvs 文件,然后将它传递给 mysql。我需要对其进行一些编辑,但我刚刚开始根据http://csv.thephpleague.com 手册编辑日期格式。
<?php
if (!ini_get("auto_detect_line_endings")) {
ini_set("auto_detect_line_endings", '1');
}
use League\Csv\Reader;
$reality = Reader::createFromPath('Workbook3.csv');
$planed = Reader::createFromPath('Workbook4.csv');
/*this function removes the "First name" "Second name" elements and
creates one that actually has the entier name in capital*/
$functionHRT = function ($row) {
$row['hrtData'] => DateTimeImmutable::createFromFormat($row['Contract Start'], 'd-m-Y'); /*this is line 18*/
}
$hrtData = $reality
// ->setOffset(7);
->fetchAssoc( , $functionHRT());
$hrtData[0]['Contract Start']->format('Y-m-d');
?>
当我尝试运行它时,我得到一个:
Parse error: parse error in /Users/nefeli/Code/ph/script.php on line 18
错误代码。我不确定问题语法错误是什么。对此有何见解?
【问题讨论】:
标签: php mysql csv import-from-excel