Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $csv = new SplFileObject("php://filter/read=convert.iconv.cp932.utf-8/resource=sample.csv", "r");
- $csv->setFlags(SplFileObject::READ_CSV | SplFileObject::DROP_NEW_LINE);
- $columns = array(
- 0 => 'id',
- 2 => 'name',
- 3 => 'deleted'
- );
- foreach ($csv as $row) {
- $user = Users::save(
- array_combine(
- array_values($columns),
- array_map(function($i) use($row) {return $row[$i];}, array_keys($columns))
- )
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement