本文整理汇总了PHP中csv_explode函数的典型用法代码示例。如果您正苦于以下问题:PHP csv_explode函数的具体用法?PHP csv_explode怎么用?PHP csv_explode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了csv_explode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_csv
function parse_csv($data)
{
$data = str_replace("\r", '', $data);
$lines = csv_explode("\n", $data, "\"");
$csv_lines = array();
foreach ($lines as $line) {
if (trim(trim($line, chr(0xc2) . chr(0xa0))) == '') {
continue;
}
$line = csv_explode("\t", $line, "\"");
$cells = array();
foreach ($line as $cell) {
$cells[] = preg_replace('/[\\x00-\\x1F]/', '', $cell);
}
$csv_lines[] = $cells;
}
return $csv_lines;
}
示例2: ref_get_data
function ref_get_data($page, $uniquekey = 1)
{
$file = ref_get_filename($page);
if (!file_exists($file)) {
return array();
}
$result = array();
$fp = @fopen($file, 'r');
set_file_buffer($fp, 0);
@flock($fp, LOCK_EX);
rewind($fp);
while ($data = @fgets($fp, 8192)) {
$data = csv_explode(',', $data);
$result[rawurldecode($data[$uniquekey])] = $data;
}
@flock($fp, LOCK_UN);
fclose($fp);
return $result;
}
示例3: import_csv
function import_csv($window)
{
global $statusbar;
$filename = wb_sys_dlg_open($window, "Import CSV", "CSV files (*.csv, *.txt)*.csv;*.txtAll files (*.*)*.*" . "");
if ($filename) {
$csv = file($filename);
} else {
return false;
}
$n = 0;
foreach ($csv as $line) {
$line = trim($line);
if ($line) {
$entry = csv_explode(stripcslashes($line));
if (edit_record("item", 0, "name\ndescription\ncat\npriority\nseverity", $entry)) {
$n++;
}
}
}
wb_set_text($statusbar, basename($filename) . " imported successfully ({$n} items added).");
return true;
}
示例4: while
if ($match === false) {
$found2[$i] = -1;
} else {
$found2[$i] = $match;
if ($columns[$match] == 'associate number') {
$realtorid = $match;
}
if ($columns[$match] == 'office id') {
$officeid = $match;
}
}
}
while (!feof($handle)) {
$data = fgets($handle, 4096);
$data = str_replace("'", "", $data);
$col = csv_explode(',', $data, '"');
$update = false;
$sql = 'select * from tb_other_realtors where realtorid="' . $col[$realtorid] . '"';
$res = mysql_query($sql);
if (mysql_num_rows($res) > 0) {
$update = true;
$list = mysql_fetch_array($res, MYSQL_ASSOC);
$isql = 'update tb_other_realtors set office="' . $offices[$col[$officeid]] . '"';
} else {
$isql = 'insert into tb_other_realtors (office,';
$k = count($fieldsneeded);
for ($j = 1; $j < $k; $j++) {
if ($datafield[$j] != '') {
if ($found2[$j] >= 0) {
if ($j < count($datafield) && $j > 1) {
$isql .= ',';
示例5: toString
function toString()
{
$styles = array();
switch ($this->name) {
case 'br':
return '<p><br class="block" /></p>';
case 'hr':
return '<hr class="short_line" />';
case 'ref':
$param = $this->param != '' ? csv_explode(',', $this->param) : array();
return guiedit_convert_ref($param);
case 'clear':
$styles[] = 'clear:both;';
}
if ($this->text) {
$this->text = str_replace(' ', ' ', _htmlspecialchars($this->text));
$this->text = preg_replace("/\r/", "<br />", $this->text);
}
$this->param = _htmlspecialchars($this->param);
$inner = "#{$this->name}" . ($this->param ? "({$this->param})" : '') . $this->text;
if (MSIE) {
$styles[] = 'cursor:default;';
}
$style = '';
if ($styles) {
$style = ' style="' . join('', $styles) . '"';
}
//$inner = '<pre>'. $inner . '</pre>';
global $xpwiki;
$attr = $xpwiki->func->exist_plugin_convert($this->name) ? ' class="plugin" contenteditable="true"' : '';
return $this->wrap($inner, 'div', $attr . $style);
}
示例6: plugin_table_edit2_action
//.........这里部分代码省略.........
//show header
if (preg_match('/title_r=(\\d+)/i', $matches[2], $m_row_title)) {
$row_title = $m_row_title[1];
}
}
if ($edit_show) {
$show->text_type($matches[2]);
}
if (isset($vars['table_mod'])) {
//table_mod
$notimestamp = TRUE;
$args_line = $chg->table_mod_chg($matches, $args_line);
}
}
$end_line = strlen($matches[3]);
}
}
if (isset($end_line) && preg_match('/^\\}{' . $end_line . '}/', $args_line) || !isset($end_line)) {
$table_find = 0;
}
if ($table_find && $table_num == $count && !isset($vars['table_mod']) && !$setting && !$import) {
$table_sub_num_count_chk = 0;
$table_f_chose = preg_match('/^\\|(.+)\\|([hHfFcC]?)$/', $args_line, $match_line) ? 1 : 0;
if ($args_line[0] == ',' && $args_line != ',') {
$table_f_chose = 2;
}
if ($td_edit || $tr_edit) {
$edit->chose = $table_f_chose;
}
if ($table_f_chose) {
if ($table_f_chose === 1) {
$match_t = explode("|", $match_line[1]);
} elseif ($table_f_chose === 2) {
$match_t = csv_explode(',', substr(str_replace("\n", '', $args_line), 1));
$match_line = array(1 => join(',', $match_t), 2 => '');
}
if ($export) {
$csv_export_data[] = $match_line[1];
}
if (isset($vars['table_sub_num']) && $table_sub_num === $vars['table_sub_num'] && $table_sub_num_chk) {
//td 06.09.18
$show->chk_table_sub_first_line = $line_count;
$table_sub_num_chk = 0;
}
if (isset($vars['line_count']) && $vars['line_count'] === $line_count || strtolower($match_line[2]) === 'h' || $edit_mod == 'tdshow' || $td_edit || $row_title) {
// $match_t = explode("|", $match_line[1]);
if ($edit_mod == 'tdshow') {
//tdshow - td_title - 06.11.11
$show->td_title[$line_count] = $match_t[$td_title_count];
}
}
if ($edit_mod == 'show') {
//show header
if ($match_line[2] == 'h' && !$row_title) {
$show->table_header($match_t);
}
if ($line_count == $row_title) {
$show->table_header($match_t);
}
}
if ($vars['line_count'] == $line_count || $table_sub_num == $vars['table_sub_num']) {
// textarea 06.11.12
if ($edit_show) {
if ($show->t_type == 'textarea') {
$show->text_type_textarea(count($match_t));
}
示例7: replace_plugin_options
function replace_plugin_options($oldoption, $optionnum, $newoption, $regexp, $plugin_strs)
{
if ($oldoption == '' && $optionnum == '') {
return $plugin_strs;
}
$search = '/^([^(]+)(?:\\(([^\\r]*)\\))(.*)$/';
foreach ($plugin_strs as $i => $line) {
$matches = array();
if (preg_match($search, $line, $matches) == 0) {
continue;
}
$head =& $matches[1];
$options =& $matches[2];
$tail =& $matches[3];
$options = csv_explode(',', $options);
foreach ($options as $j => $option) {
if (strpos($option, ',') !== FALSE) {
$options[$j] = '"' . $option . '"';
// csv recover
}
}
if ($oldoption != '') {
foreach ($options as $j => $option) {
if ($options[$j] == '') {
continue;
}
if ($regexp) {
$options[$j] = preg_replace('/' . str_replace('/', '\\/', $oldoption) . '/', $newoption, $options[$j]);
} else {
$options[$j] = $oldoption == $option ? $newoption : $options[$j];
//$options[$j] = str_replace($oldoption, $newoption, $options[$j]);
}
if ($options[$j] == '') {
unset($options[$j]);
}
}
} else {
$num = $optionnum >= 0 ? $optionnum : count($options) + $optionnum;
if ($regexp) {
$options[$num] = preg_replace(preg_quote($options[$num], '/'), $newoption, $options[$num]);
} else {
$options[$num] = $newoption;
}
if ($options[$num] == '') {
unset($options[$num]);
}
}
// no csv implode.
$options = implode(',', $options);
$plugin_strs[$i] = "{$head}({$options}){$tail}";
}
return $plugin_strs;
}
示例8: splitbody
function splitbody(&$body)
{
$lines = explode("\n", $body);
$splitargs = array();
$bodies = array();
$line = current($lines);
$matches = array();
if (preg_match('/' . $this->splittag . '(?:\\(([^)]*)\\))?(.*)$/', $line, $matches)) {
$splitargs[] = csv_explode(',', $matches[1]);
$bodies[0] = '';
} else {
$bodies[0] = $line . "\n";
}
$i = 0;
while (($line = next($lines)) !== false) {
$matches = array();
if (preg_match('/' . $this->splittag . '(?:\\(([^)]*)\\))?(.*)$/', $line, $matches)) {
$splitargs[] = csv_explode(',', $matches[1]);
$bodies[++$i] = '';
} else {
$bodies[$i] .= $line . "\n";
}
}
if (count($bodies) > count($splitargs)) {
array_unshift($splitargs, array());
}
return array(&$bodies, &$splitargs);
}
示例9: tb_get
function tb_get($file, $key = 1)
{
if (!file_exists($file)) {
return array();
}
$result = array();
$fp = @fopen($file, 'r');
set_file_buffer($fp, 0);
@flock($fp, LOCK_EX);
rewind($fp);
while ($data = @fgets($fp, 8192)) {
// $data[$key] = URL
$data = csv_explode(',', $data);
$result[rawurldecode($data[$key])] = $data;
}
@flock($fp, LOCK_UN);
fclose($fp);
return $result;
}
示例10: ninja_forms_import_list_options
function ninja_forms_import_list_options()
{
$options = $_REQUEST['options'];
$field_id = absint($_REQUEST['field_id']);
$options = str_replace('\\,', '-comma-replace-placeholder-', $options);
$options = csv_explode($options);
if (is_array($options)) {
$tmp_array = array();
$x = 0;
foreach ($options as $option) {
$label = stripslashes($option[0]);
$value = stripslashes($option[1]);
$calc = stripslashes($option[2]);
$label = str_replace("''", "", $label);
$label = str_replace("-comma-replace-placeholder-", ",", $label);
$value = str_replace("''", "", $value);
$value = str_replace("-comma-replace-placeholder-", ",", $value);
$calc = str_replace("''", "", $calc);
$calc = str_replace("-comma-replace-placeholder-", ",", $calc);
$tmp_array[$x]['label'] = $label;
$tmp_array[$x]['value'] = $value;
$tmp_array[$x]['calc'] = $calc;
$x++;
}
$x = 0;
foreach ($tmp_array as $option) {
$hidden = 0;
ninja_forms_field_list_option_output($field_id, $x, $option, $hidden);
$x++;
}
}
die;
}
示例11: bank_import_csv
function bank_import_csv($structure, $filename, $bank_gl_acct)
{
global $db, $messageStack;
include DIR_FS_WORKING . 'classes/import_banking.php';
$bankimport = new impbanking();
$data = file($_FILES[$filename]['tmp_name']);
// read the header and build array
if (sizeof($data) < 2) {
$messageStack->add('The number of lines in the file is to small, a csv file must contain a header line and at least on input line!', 'error');
return false;
}
$header = csv_explode(trim(array_shift($data)));
// build the map structure
$temp = $structure->Module->Table;
$map_array = array();
foreach ($structure->Module->Table as $table) {
foreach ($table->Field as $field) {
$key = array_search($field->TagName, $header);
if ($key !== false) {
$map_array[$key] = array('cnt' => 0, 'table' => $table->Name, 'field' => $field->Name);
}
}
break;
}
// build dependent map tables
$ref_mapping = array();
if (is_object($table->LinkTable)) {
$table->LinkTable = array($table->LinkTable);
}
if (isset($table->LinkTable)) {
foreach ($table->LinkTable as $subtable) {
foreach ($structure->Module->Table as $working) {
if ($subtable->Name == $working->Name) {
$ref_mapping[$subtable->Name] = array('pri_field' => $subtable->PrimaryField, 'ref_field' => $subtable->DependentField);
for ($i = 1; $i <= MAX_IMPORT_CSV_ITEMS; $i++) {
foreach ($working->Field as $field) {
$key = array_search($field->TagName . '_' . $i, $header);
if ($key !== false) {
$map_array[$key] = array('cnt' => $i, 'table' => $subtable->Name, 'field' => $field->Name);
}
}
}
}
}
}
}
$countline = 0;
foreach ($data as $line) {
if (!($line = trim($line))) {
continue;
}
// blank line
$line_array = $map_array;
$sql_array = array();
$working = csv_explode($line);
for ($i = 0; $i < sizeof($working); $i++) {
$line_array[$i]['value'] = $working[$i];
}
foreach ($line_array as $value) {
$sql_array[$value['table']][$value['cnt']][$value['field']] = $value['value'];
}
$db->transStart();
foreach ($sql_array as $table => $count) {
foreach ($count as $cnt => $table_array) {
if ($table_array['debit_amount'] == '' && $table_array['credit_amount'] == '') {
if ($table_array['debit_credit'] == DEBIT_CREDIT_DESCRIPTION) {
$table_array['debit_amount'] = 0;
$table_array['credit_amount'] = $table_array['amount'];
} else {
$table_array['debit_amount'] = $table_array['amount'];
$table_array['credit_amount'] = 0;
}
}
if (isset($table_array['debit_amount']) && isset($table_array['credit_amount'])) {
// echo 'inserting data: '; print_r($table_array); echo '<br>';
$bankimport->start_import($table_array['our_account_number'], $table_array['date'], $table_array['account_number_to'], $table_array['credit_amount'], $table_array['debit_amount'], $table_array['description'] . ' ' . $table_array['anouncement'], $bank_gl_acct, $table_array['iban_to']);
if ($bankimport->_succes == true) {
$countline++;
}
}
}
}
}
if ($countline != 0) {
if (!$bankimport->update_chart_history_periods($bankimport->first_period)) {
$db->transRollback();
$messageStack->add("Chart of accounts are out of balance. When we try to import the file\n Removed the journals. Please try to import again when balances are fine.");
} else {
$db->transCommit();
$messageStack->add("succesfully posted {$countline} number of lines", 'caution');
}
}
$messageStack->write_debug();
}
示例12: read_updatelist
function read_updatelist()
{
$datfile = CACHE_DIR . 'updateplugin.dat';
$lines = file($datfile);
$list = array();
foreach ($lines as $line) {
$metas = csv_explode(',', rtrim($line));
$data = array();
foreach ($metas as $meta) {
list($key, $val) = explode('=', $meta, 2);
$data[$key] = $val;
}
$list[$data['filename']] = $data;
}
return $list;
}
示例13: Factory_InlineEx
function &Factory_YTableEx(&$root, $text)
{
if ($text == ',') {
return Factory_InlineEx($text);
} else {
// return new YTableEx(csv_explode(',', substr($text, 1)));
$obj = new YTableEx(csv_explode(',', substr($text, 1)));
return $obj;
}
}
示例14: r_metalines
function r_metalines($page, $detected = false)
{
if (array_key_exists($page, $this->visited)) {
return array();
}
if (!is_page($page)) {
return array();
}
$this->visited[$page] = '';
$lines = $this->get_source($page);
$multiline = 0;
$metalines = array();
foreach ($lines as $i => $line) {
// multiline plugin. refer lib/convert_html
if (defined('PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK') && PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK === 0) {
$matches = array();
if ($multiline < 2) {
if (preg_match('/^#([^\\(\\{]+)(?:\\(([^\\r]*)\\))?(\\{*)/', $line, $matches)) {
$multiline = strlen($matches[3]);
}
} else {
if (preg_match('/^\\}{' . $multiline . '}$/', $line, $matches)) {
$multiline = 0;
}
continue;
}
}
// fromhere
if ($this->options['page'][1] == $page && !$detected) {
if (preg_match('/^#' . $this->plugin . '/', $line, $matches)) {
$detected = true;
continue;
}
}
if (preg_match($this->conf['def_headline'], $line, $matches)) {
$depth = strlen($matches[1]);
$anchor = '#' . $this->make_heading($line);
// *** [id] is removed from $line
$headline = trim($line);
$metalines[] = array(page => $page, headline => $headline, anchor => $anchor, depth => $depth, linenum => $i, fromhere => $detected);
continue;
}
if (preg_match($this->conf['def_include'], $line, $matches)) {
$args = csv_explode(',', $matches[1]);
$inclpage = array_shift($args);
$options = array();
foreach ($args as $arg) {
list($key, $val) = array_pad(explode('=', $arg, 2), 2, true);
$options[$key] = $val;
}
$inclpage = get_fullname($inclpage, $page);
if (!$this->is_page($inclpage)) {
continue;
}
// $anchor = PluginIncludex::get_page_anchor($inclpage)
$anchor = 'z' . md5($inclpage);
$anchor = '#' . htmlspecialchars($anchor);
if (exist_plugin('includex') & is_callable(array('PluginIncludex', 'get_titlestr'))) {
$titlestr = PluginIncludex::get_titlestr($inclpage, $options['titlestr']);
} else {
$titlestr = $inclpage;
}
$metalines[] = array(page => $inclpage, headline => $titlestr, anchor => $anchor, depth => 0, linenum => $i, fromhere => $detected);
$metalines = array_merge($metalines, $this->r_metalines($inclpage, $detected));
continue;
}
if (preg_match($this->conf['def_title'], $line, $matches)) {
$title = $matches[1];
$this->visited[$page] = $title;
continue;
}
}
return $metalines;
}
示例15: do_plugin_inline
function do_plugin_inline($name, $args, &$body)
{
global $digest;
if (do_plugin_init($name) === FALSE) {
return '[Plugin init failed: ' . $name . ']';
}
if ($args !== '') {
$aryargs = csv_explode(',', $args);
} else {
$aryargs = array();
}
// NOTE: A reference of $body is always the last argument
$aryargs[] =& $body;
// func_num_args() != 0
$_digest = $digest;
$retvar = call_user_func_array('plugin_' . $name . '_inline', $aryargs);
$digest = $_digest;
// Revert
if ($retvar === FALSE) {
// Do nothing
return htmlsc('&' . $name . ($args ? '(' . $args . ')' : '') . ';');
} else {
return $retvar;
}
}