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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| <?php
$fichier = 'fichier_global_offer.xml';
$xml = simplexml_load_file($fichier);
$planOffer = $xml->xpath('//Niv2_Offre');
$planOperation = $xml->xpath('//Niv1_Operation');
$m=0;
foreach ($planOffer as $offer)
{
$code = $offer->{"Informations"}->{"Code"};
$offerName = $offer->{"Informations"}->{"Designation"};
$catOne = $offer->{"Informations"}->{"Categorie_Un"};
$catTwo = $offer->{"Informations"}->{"Categorie_Deux"};
$parentCode = $offer->{"Code"}->{"Code_Niv1"};
$beginDate = $offer->{"Criteres"}->{"Date_de_debut"};
$endDate = $offer->{"Criteres"}->{"Date_de_fin"};
$client = $offer->{"Criteres"}->{"Client"};
$execution = $offer->{"Criteres"}->{"Execution"};
$exclusion = $offer->{"Criteres"}->{"Articles_OUT"};
$canalDistrib = $offer->{"Criteres"}->{"canal_Distribution"};
if(empty($canalDistrib))
{
$canalDistrib = "mag";
}
foreach ($planOperation as $operation)
{
$opeCode = $operation->{"Code_operation"};
if($opeCode == $parentCode)
{
$operationName=$operation->{"Nom_operation"};
}
else
{
$operationName='non';
}
}
$desc='cible'.$client. ' - opération "'.$operationName.'" - code'.$code.' '.$offerName.' '.$execution.' // '.$canalDistrib.' Marques exclues : '.$exclusion.' Date de validité : du '.$beginDate.' au '.$endDate;
$array_offerPlan[$m]=array(
array('CAT1' => $catTwo,
'CAT2' => $catOne,
'INFO' => $desc));
$m++;
}
var_dump($array_offerPlan);
uasort($array_offerPlan, 'cmp');
//$array_offerPlan2 = array_msort($array_offerPlan, array('CAT1' => SORT_DESC, 'CAT2' => SORT_DESC));
//var_dump($array_offerPlan, $array_offerPlan2);
var_dump($array_offerPlan);
function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
/*function array_msort($array, $cols)
{
$colarr = array();
foreach ($cols as $col => $order) {
$colarr[$col] = array();
foreach ($array as $k => $row) { $colarr[$col]['_'.$k] = strtolower($row[$col]); }
}
$eval = 'array_multisort(';
foreach ($cols as $col => $order) {
$eval .= '$colarr[\''.$col.'\'],'.$order.',';
}
$eval = substr($eval,0,-1).');';
eval($eval);
$ret = array();
foreach ($colarr as $col => $arr) {
foreach ($arr as $k => $v) {
$k = substr($k,1);
if (!isset($ret[$k])) $ret[$k] = $array[$k];
$ret[$k][$col] = $array[$k][$col];
}
}
return $ret;
}*/
?> |
Partager