-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo-old.php
52 lines (36 loc) · 1.17 KB
/
demo-old.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require_once("parsecsv-for-php/parsecsv.lib.php");
// on déclare le parser (l'analyseur)
$csv = new ParseCsv\Csv();
$csv->encoding('UTF-16', 'UTF-8');
$csv->delimiter = ";";
// on parse les données (on les analyse, on les filtre)
$csv->parse('tableau-de-mots.csv');
print_r($csv->data);
// echo ± print_r
// print_r( count( $csv->data ) . "\n" );
/*
function cmp($a, $b) {
if ( strtolower($a['Nom']) == strtolower($b['Nom']) ) {
//return 0;
if ( strtolower($a['Mot']) == strtolower($b['Mot']) ) {
return 0;
}
return ( strtolower($a['Mot']) < strtolower($b['Mot']) ) ? -1 : 1;
}
return ( strtolower($a['Nom']) < strtolower($b['Nom']) ) ? -1 : 1;
}
uasort($csv->data, 'cmp');
$xml = "<livre>";
foreach( $csv->data as $ligne ){
$xml .= "<nom><prenom>".$ligne["Prénom"] . "</prenom> " . $ligne["Nom"]."</nom>\n";
$xml .= "<mot>".$ligne["Mot"] . "</mot>\n";
$xml .= "<definition>".$ligne["Définition"] . "</definition>\n";
// print_r( "=>\t" .$ligne["Prénom"] . " " . $ligne["Nom"] . "\n" );
// print_r( "\t[ " .$ligne["Mot"] . " ]\n" );
// print_r( $ligne['Définition'] . "\n" );
}
$xml .= "</livre>";
echo $xml;
file_put_contents("livre.xml", $xml);
*/