Comment fait t'on pour compter combien de $tpl[0] il y a.. ?
Une fonction ..
Moi j'ai le code suivant :
$str = 'Cédrick,Jasmin,"1,50m",yeux bleu';
$i = 0; // str[X]
$j = 0; // tpl[X][]
$delim = false;
$len = strlen($str);
$tpl = array();
for(; $i<$len; $i++) {
if ($str[$i] == '"') {
$delim = $delim ? false : true;
$j++;
} else if ($str[$i] == ',' && !$delim) {
$j++;
} else {
$tpl[$j] .= $str[$i];
}
}
$nbVar = count($tpl);
for($k='0'; $k<$nbVar; $k++)
{
echo $tpl[$k].' ';
}
Mais le code va afficher seulement (Cédrick Jasmin 1,50m)
et moi je voudrait :
Cédrick Jasmin 1,50m yeux bleu