1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <?
$arr_res = array();
$arr_res[] = array("indice" => "1","libelle" => "toto");
$arr_res[] = array("indice" => "2","libelle" => "tata");
$arr_res[] = array("indice" => "3","libelle" => "titi");
$arr_res[] = array("indice" => "4","libelle" => "tutu");
$arr_res[] = array("indice" => "5","libelle" => "tete");
$arr_res[] = array("indice" => "6","libelle" => "dodo");
$arr_res[] = array("indice" => "7","libelle" => "dada");
$arr_res2 = array();
$arr_res2[] = array("indice" => "1","nb" => "10");
$arr_res2[] = array("indice" => "2","nb" => "20");
$arr_res2[] = array("indice" => "3","nb" => "30");
$arr_res2[] = array("indice" => "6","nb" => "40");
$arr_res2[] = array("indice" => "7","nb" => "50");
$arr_res2[] = array("indice" => "8","nb" => "45");
echo "RES\n";
foreach($arr_res as $key => $value)
{
echo "indice ".$value["indice"]." libelle ".$value["libelle"]."\n";
}
echo "RES 2\n";
foreach($arr_res2 as $key2 => $value2)
{
echo "indice ".$value2["indice"]." nb ".$value2["nb"]."\n";
}
echo "RES 3\n";
$arr_res3 = array();
foreach($arr_res as $key => $value)
{
foreach($arr_res2 as $key2 => $value2)
{
if(!strcmp($value2["indice"],$value["indice"]))
{
$arr_res3[] = array("indice" => $value["indice"], "libelle" => $value["libelle"] , "nb" => $value2["nb"] );
}
}
}
foreach($arr_res3 as $key3 => $value3)
{
echo "indice ".$value3["indice"]." libelle ".$value3["libelle"]." nb ".$value3["nb"]."\n";
}
?> |
Partager