pioug43
Messages postés32Date d'inscriptionlundi 23 décembre 2002StatutMembreDernière intervention 3 novembre 2006
-
10 août 2005 à 00:18
arnal69130
Messages postés445Date d'inscriptionlundi 17 février 2003StatutMembreDernière intervention22 mars 2007
-
10 août 2005 à 15:51
Bonjour,
Je recherhce une fonction qui pourrait me traduire
un tableau vers une string et inversement de plus la fonction etre
recurcive puisqu'un tableau peut aussi contenir un tableau
J'ai trouve ce bout de code mais je n'arrive pas à voir comment je
pourrais integre qu'un tableau peut aussi contenir un tableau et ainsi
de suite
// Converts an array to a string that is safe to pass via a URL
function array_to_string($array) {
$retval = '';
foreach ($array as $index => $value) {
$retval .= urlencode(base64_encode($index)) . '|' . urlencode(base64_encode($value)) . '||';
}
return urlencode(substr($retval, 0, -2));
}
// Converts a string created by array_to_string() back into an array.
function string_to_array($string) {
$retval = array();
$string = urldecode($string);
$tmp_array = explode('||', $string);
foreach ($tmp_array as $tmp_val) {
list($index, $value) = explode('|', $tmp_val);
$retval[base64_decode(urldecode($index))] = base64_decode(urldecode($value));
}
return $retval;
}
function tableauVersChaine($sep,$tableau){
foreach($tableau as $cle=>$val){
if (is_array($val))
$tableau[$cle]=tableauVersChaine($sep,$val);
}
return implode($sep,$tableau);
}