当前位置: 首页>>代码示例>>PHP>>正文


PHP format::csv_to_arr方法代码示例

本文整理汇总了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) {
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:67,代码来源:Users.php


注:本文中的format::csv_to_arr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。