Possible en double:
Display array elements in smartyéléments d'affichage du tableau multidimensionnel dans Smarty
J'ai fusionné deux résultats mysql:
while($rs_1 = mysql_fetch_array($r1)) {
$arr1[] = $rs_1;
}
while($rs_2 = mysql_fetch_array($r2)) {
$arr2[] = $rs_2;
}
$resN = array_merge($arr1,$arr2);
var_dump($resN)
montre le résultat suivant:
array(5) {
[0]=> array(4) {
[0]=> string(6) "Petric"
["bz_pro_first_name"]=> string(6) "Petric"
[1]=> string(8) "Naughton"
["bz_pro_last_name"]=> string(8) "Naughton"
}
[1]=> array(4) {
[0]=> string(6) "Nitish"
["bz_pro_first_name"]=> string(6) "Nitish"
[1]=> string(12) "Dolakasharia"
["bz_pro_last_name"]=> string(12) "Dolakasharia"
}
[2]=> array(4) {
[0]=> string(6) "Martin"
["bz_pro_first_name"]=> string(6) "Martin"
[1]=> string(3) "Rom"
["bz_pro_last_name"]=> string(3) "Rom"
}
[3]=> array(4) {
[0]=> string(5) "Steve"
["bz_pro_first_name"]=> string(5) "Steve"
[1]=> string(5) "Wough"
["bz_pro_last_name"]=> string(5) "Wough"
}
[4]=> array(4) {
[0]=> string(3) "Liz"
["bz_pro_first_name"]=> string(3) "Liz"
[1]=> string(6) "Hurley"
["bz_pro_last_name"]=> string(6) "Hurley"
}
}
je suis censé les afficher dans Smarty si:
assign_values('rand_pro',$resN);
Maintenant j'ai essayé d'afficher dans Smarty comme ceci:
{foreach name=outer item=pro from=$rand_pro}
{foreach key=key item=item from=$pro}
{$key}: {$item}<br />
{/foreach}
{/foreach}
Il affiche les résultats, mais en série. J'ai besoin d'extraire les valeurs dans certaines positions. Alors, comment puis-je extraire les valeurs, par exemple le prénom, le nom de famille, etc?