Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 65 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 65 Rev 474
Line 1... Line 1...
1
<?php
1
<?php
2
class Outils {
2
class Outils {
-
 
3
 
3
	public static function recupererTableauConfig($parametres) {
4
	public static function recupererTableauConfig($parametres) {
4
		$tableau = array();
5
		$tableau = array();
5
		$tableauPartiel = explode(',', $parametres);
6
		$tableauPartiel = explode(',', $parametres);
6
		$tableauPartiel = array_map('trim', $tableauPartiel);
7
		$tableauPartiel = array_map('trim', $tableauPartiel);
7
		foreach ($tableauPartiel as $champ) {
8
		foreach ($tableauPartiel as $champ) {
Line 59... Line 60...
59
 
60
 
60
			echo str_repeat(chr(8), (strlen((string) $actuel) - $passage));
61
			echo str_repeat(chr(8), (strlen((string) $actuel) - $passage));
61
			echo $actuel++;
62
			echo $actuel++;
62
		}
63
		}
-
 
64
	}
-
 
65
 
-
 
66
	/**
-
 
67
	 * @link http://gist.github.com/385876
-
 
68
	 */
-
 
69
	public function transformerTxtTsvEnTableau($file = '', $delimiter = "\t") {
-
 
70
		$str = file_get_contents($file);
-
 
71
		$lines = explode("\n", $str);
-
 
72
		$field_names = explode($delimiter, array_shift($lines));
-
 
73
		foreach ($lines as $line) {
-
 
74
			// Skip the empty line
-
 
75
			if (empty($line)) continue;
-
 
76
			$fields = explode($delimiter, $line);
-
 
77
			$_res = array();
-
 
78
			foreach ($field_names as $key => $f) {
-
 
79
				$_res[$f] = isset($fields[$key]) ? $fields[$key] : '';
-
 
80
			}
-
 
81
			$res[] = $_res;
-
 
82
		}
-
 
83
		return $res;
63
	}
84
	}
64
}
85
}
65
?>
86
?>