本文整理汇总了PHP中format::csv_to_arr方法的典型用法代码示例。如果您正苦于以下问题:PHP format::csv_to_arr方法的具体用法?PHP format::csv_to_arr怎么用?PHP format::csv_to_arr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format
的用法示例。
在下文中一共展示了format::csv_to_arr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
//.........这里部分代码省略.........
$acceptColl[] = $collection->get_label($app['locale']);
continue;
}
$denyColl[] = $collection->get_label($app['locale']);
}
if (0 !== count($acceptColl) || 0 !== count($denyColl)) {
$message = '';
if (0 !== count($acceptColl)) {
$message .= "\n" . $app->trans('login::register:email: Vous avez ete accepte sur les collections suivantes : ') . implode(', ', $acceptColl) . "\n";
}
if (0 !== count($denyColl)) {
$message .= "\n" . $app->trans('login::register:email: Vous avez ete refuse sur les collections suivantes : ') . implode(', ', $denyColl) . "\n";
}
$receiver = new Receiver(null, $user->getEmail());
$mail = MailSuccessEmailUpdate::create($app, $receiver, null, $message);
$app['notification.deliverer']->deliver($mail);
}
}
}
return $app->redirectPath('users_display_registrations', ['success' => 1]);
})->bind('users_submit_registrations');
$controllers->get('/import/file/', function (Application $app, Request $request) {
return $app['twig']->render('admin/user/import/file.html.twig');
})->bind('users_display_import_file');
$controllers->post('/import/file/', function (Application $app, Request $request) {
if (null === ($file = $request->files->get('files')) || !$file->isValid()) {
return $app->redirectPath('users_display_import_file', ['error' => 'file-invalid']);
}
$equivalenceToMysqlField = self::getEquivalenceToMysqlField();
$loginDefined = $pwdDefined = $mailDefined = false;
$loginNew = [];
$out = ['ignored_row' => [], 'errors' => []];
$nbUsrToAdd = 0;
$lines = \format::csv_to_arr($file->getPathname());
$roughColumns = array_shift($lines);
$columnsSanitized = array_map(function ($columnName) {
return trim(mb_strtolower($columnName));
}, $roughColumns);
$columns = array_filter($columnsSanitized, function ($columnName) use(&$out, $equivalenceToMysqlField) {
if (!isset($equivalenceToMysqlField[$columnName])) {
$out['ignored_row'][] = $columnName;
return false;
}
return true;
});
foreach ($columns as $columnName) {
if ($equivalenceToMysqlField[$columnName] === 'usr_login') {
$loginDefined = true;
}
if ($equivalenceToMysqlField[$columnName] === 'usr_password') {
$pwdDefined = true;
}
if ($equivalenceToMysqlField[$columnName] === 'usr_mail') {
$mailDefined = true;
}
}
if (!$loginDefined) {
return $app->redirectPath('users_display_import_file', ['error' => 'row-login']);
}
if (!$pwdDefined) {
return $app->redirectPath('users_display_import_file', ['error' => 'row-pwd']);
}
if (!$mailDefined) {
return $app->redirectPath('users_display_import_file', ['error' => 'row-mail']);
}
foreach ($lines as $nbLine => $line) {