par
Aureusms » 10 avr. 2010, 20:39
Tiens, j'ai un peu de temps
$string = '{"1":2,"2":1,"3":2,"4":2,"5":1}';
$string = str_replace (array("{","}"),array("",""),$string);
echo $string;
$tableau_temporaire = explode (',',$string);
foreach ($tableau_temporaire as $cle => $valeur)
{
$tab = explode (":",$valeur);
$tableau_finale[$cle][0] = str_replace('"','',$tab[0]);
$tableau_finale[$cle][1] = intval($tab[1]);
}
echo '<pre>';
print_r ($tableau_finale);
echo '</pre>';
Tiens, j'ai un peu de temps
[php]$string = '{"1":2,"2":1,"3":2,"4":2,"5":1}';
$string = str_replace (array("{","}"),array("",""),$string);
echo $string;
$tableau_temporaire = explode (',',$string);
foreach ($tableau_temporaire as $cle => $valeur)
{
$tab = explode (":",$valeur);
$tableau_finale[$cle][0] = str_replace('"','',$tab[0]);
$tableau_finale[$cle][1] = intval($tab[1]);
}
echo '<pre>';
print_r ($tableau_finale);
echo '</pre>';[/php]