"Cannot use object of type Panier as array in ..."
<?php //http://www.allhtml.com/articles/detail/523 class Panier { private $panier = array(); public function __construct () { if(!isset($_SESSION['panier'])) $_SESSION['panier'] = array(); $this->panier =& $_SESSION['panier']; } public function cle($idArticle) { $res = "non"; foreach ($this->panier as $key => $tab) { if($tab["idProduit"] == $idArticle) $res = $key; } return $res; } public function ajoutArticle($array) { //idProduit //nom //Modele //urlPhoto //idRub //rub //nomQte //idQte //qte //PrixU if($this->cle($array["idProduit"] != 'non')) $this->supprArticle($array["idProduit"]); $this->panier[] = $array; } public function qteArticle ($id, $qte) { $this->panier[$this->cle($id)]['qte'] = $qte; } public function supprArticle($id) { //unset ($this->panier[$this->cle($id)]); foreach ($this->panier as $key => $tab) { if($tab["idProduit"] == $id) unset($this->panier[$key]); } } public function nbrArticle () { return count($this->panier); } public function totalTTCArticle ($id) { return $this->panier[$this->cle($id)]['qte'] * $this->panier[$this->cle($id)]['PrixU']; } public function totalTTC () { $total = 0; foreach ($this->panier as $key => $tab) { $total = $total + ($tab["PrixU"] * $tab["qte"]); } return $total; } public function affPanier() { $list = $this->returnPanier(); if(sizeof($list) == 0) { return 'Votre panier est vide. '; }else{ $x = 0; $html = ''; foreach($list as $key => $val) { $prixTot = $val[\"qte\"] * $val[\"PrixU\"]; $classLigne (($x % 2) 0) ? 'class=\"lignPaire\"' : 'class=\"lignImpaire\"'; $nom = $val[\"qte\"].'x '.$val[\"nom\"]; $nom .= ($val[\"modele\"] != \"\") ? ' - '.$val[\"modele\"] : ''; $nom .= ($val[\"nomQte\"] != \"\") ? '('.$val[\"nomQte\"].')' : ''; $html .= ' ---- '.$nom.', '.$prixTot.'€, '; $x++; } $html .= ' ---- total | '.$this->totalTTC ().'€ | '; $html . = ' '; return $html; } } public function returnPanier() { return $this->panier; } public function ferme() { $this->panier = array(); } } ?>