當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。