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


PHP parse_csv_data函数代码示例

本文整理汇总了PHP中parse_csv_data函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_csv_data函数的具体用法?PHP parse_csv_data怎么用?PHP parse_csv_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_csv_data函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: import_users_from_file

/**
 * Import users into database from a file located on the server.
 * Function registered as service.
 * @param  string The csv (only csv) file containing users tom import
 * @param  string Security key (as found in configuration file)
 * @return string Error message
 */
function import_users_from_file($filepath, $security_key)
{
    global $_configuration;
    $errors_returned = array(0 => 'success', 1 => 'file import does not exist', 2 => 'no users to import', 3 => 'wrong datas in file', 4 => 'security error');
    // Check whether this script is launch by server and security key is ok.
    if (empty($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $security_key != $_configuration['security_key']) {
        return $errors_returned[4];
    }
    // Libraries
    require_once 'import.lib.php';
    // Check is users file exists.
    if (!is_file($filepath)) {
        return $errors_returned[1];
    }
    // Get list of users
    $users = parse_csv_data($filepath);
    if (count($users) == 0) {
        return $errors_returned[2];
    }
    // Check the datas for each user
    $errors = validate_data($users);
    if (count($errors) > 0) {
        return $errors_returned[3];
    }
    // Apply modifications in database
    save_data($users);
    return $errors_returned[0];
    // Import successfull
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:36,代码来源:service.php

示例2: array

$interbreadcrumb[] = array('url' => Container::getRouter()->generate('administration'), "name" => get_lang('PlatformAdmin'));
set_time_limit(0);
$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true);
$user_id_error = array();
$error_message = '';
if (isset($_POST['formSent']) && $_POST['formSent'] and $_FILES['import_file']['size'] !== 0) {
    $file_type = 'csv';
    Security::clear_token();
    $tok = Security::get_token();
    $allowed_file_mimetype = array('csv', 'xml');
    $error_kind_file = false;
    $uploadInfo = pathinfo($_FILES['import_file']['name']);
    $ext_import_file = $uploadInfo['extension'];
    if (in_array($ext_import_file, $allowed_file_mimetype)) {
        if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) {
            $users = parse_csv_data($_FILES['import_file']['tmp_name']);
            $errors = validate_data($users);
            $error_kind_file = false;
        } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) {
            $users = parse_xml_data($_FILES['import_file']['tmp_name']);
            $errors = validate_data($users);
            $error_kind_file = false;
        } else {
            $error_kind_file = true;
        }
    } else {
        $error_kind_file = true;
    }
    // List user id with error.
    $users_to_insert = $user_id_error = array();
    if (is_array($errors)) {
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:user_update_import.php

示例3: setInput

 public function setInput($data)
 {
     $this->title = 'PHPUnit tests : Memory';
     $this->yAxis->label = 'Test memory, bytes';
     $subdata = array();
     foreach (glob($this->prevDir . '/*/logs/phpunit.xml.speed') as $f) {
         $d = parse_csv_data($f);
         if (count($d) == 0) {
             continue;
         }
         $sum = 0;
         foreach ($d as $row) {
             $sum += $row['memory'];
         }
         $subdata[] = $sum / count($d);
     }
     $sum = 0;
     foreach ($data as $row) {
         $sum += $row['memory'];
     }
     $subdata[] = $sum / count($data);
     $this->data['Memory'] = new ezcGraphArrayDataSet($subdata);
     foreach ($this->data as $k => $v) {
         $this->data[$k]->symbol = ezcGraph::BULLET;
         foreach ($this->data[$k] as $key => $v2) {
             $this->data[$k]->symbol[$key] = ezcGraph::NO_SYMBOL;
         }
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:29,代码来源:graph-phing.php


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