J'espère que vous allez bien. Ma question:PHP Array question?
En MYSQL j'ai une table avec ce type de champ
Nom du champ: TAGS Valeur: xavier, celine, Marise, leon, john, cathy, Polux, Maurice
en PHP je fais ce
$xwords = array();
function array_rpush(&$arr, $item)
{
$arr = array_pad($arr, -(count($arr) + 1), $item);
}
$tags = requete("SELECT tags FROM tbl_tags LIMIT 1;");
while($dtags = mysql_fetch_assoc($tags)){
$words .= array_rpush($xwords, $dtags['tags']);
}
// MY ARRAY XWORDS FOR DEBUG
//
// Array ([0] => xavier, celine, marise, leon, john, cathy, polux, maurice
//
Mon script a besoin de trouver la première lettre de chaque mot dans cette liste et vérifier s'il correspond avec A/B/C (i créer une page d'index AZ)
// COUNT $XWORDS VALUE
$total = count($xwords);
// total =1
for($i=0; $i < $total; $i++)
{
$wtags = explode(",",$xwords[$i]);
// wtags = Array ([0] => xavier [1] => celine [2] => marise...)
while (list($idx,$val) = each($wtags)) {
echo $val{0}."<br>";
echo substr($val,0,1)."<br>";
}
}
echo $val{0}."<br>";
OU echo substr($val,0,1)."<br>"
me donner juste x
et rien après (tout en me donner la première lettre du premier enregistrement dans le tableau ... étonnant :))
Peut-être vous pouvez me aider à trouver une solution . Merci
Bonne prise, +1. –