示例#1
0
function filtre_text_csv_dist($t)
{
    include_spip('inc/csv');
    list($entete, $lignes) = analyse_csv($t);
    foreach ($lignes as &$l) {
        $l = join('|', $l);
    }
    $corps = join("\n", $lignes) . "\n";
    $corps = $caption . "\n|{{" . join('}}|{{', $entete) . "}}|" . "\n|" . str_replace("\n", "|\n|", $corps);
    $corps = str_replace('&#34#', '"', $corps);
    include_spip('inc/texte');
    return propre($corps);
}
示例#2
0
文件: data.php 项目: genma/spip_ynh
/**
 * csv -> tableau
 * @param string $u
 * @return array|bool
 */
function inc_csv_to_array_dist($u)
{
    include_spip('inc/csv');
    list($entete, $csv) = analyse_csv($u);
    array_unshift($csv, $entete);
    include_spip('inc/charsets');
    foreach ($entete as $k => $v) {
        $v = strtolower(preg_replace(',\\W+,', '_', translitteration($v)));
        foreach ($csv as &$item) {
            $item[$v] =& $item[$k];
        }
    }
    return $csv;
}
示例#3
0
文件: data.php 项目: JLuc/SPIP
/**
 * csv -> tableau
 * @param string $u
 * @return array|bool
 */
function inc_csv_to_array_dist($u)
{
    include_spip('inc/csv');
    list($entete, $csv) = analyse_csv($u);
    array_unshift($csv, $entete);
    include_spip('inc/charsets');
    $i = 1;
    foreach ($entete as $k => $v) {
        if (trim($v) == "") {
            $v = "col" . $i;
        }
        // reperer des eventuelles cases vides
        if (is_numeric($v) and $v < 0) {
            $v = "__" . $v;
        }
        // ne pas risquer d'ecraser une cle numerique
        if (is_numeric($v)) {
            $v = "_" . $v;
        }
        // ne pas risquer d'ecraser une cle numerique
        $v = strtolower(preg_replace(',\\W+,', '_', translitteration($v)));
        foreach ($csv as &$item) {
            $item[$v] =& $item[$k];
        }
        $i++;
    }
    return $csv;
}