8797 sujets

Développement web côté serveur, CMS

Bonjour je vais m'expliquer afin d'être clair je tente de faire plusieurs tableau html à partir d'un array en gros je souhaiterai avoir pour chaque champs spécifique un tableau html voila un exemple:

Type Nom couleur Prix

Fruit => fraise => rouge => 5,50
Fruit => pêche => orange => 4,50
Fruit => banane => jaune => 5,50
Fruit => poire => vert => 3,50

Type Nom couleur Prix

Légume => carotte => orange => 1,50
Légume => haricot => vert => 3,50
Légume => pomme de terre => jaune => 2,50

Voila donc y creer un tableau pour tous les fruits et un autres pour tous les légumes etc. Je sais pas si vous comprendrez ^^ merci d'avance.
Salut,

Un truc dans ce genre ?
$data = array(
	"fruit" => array(
		array(
			"nom" => "fraise",
			"couleur" => "rouge",
			"prix" => "5,50"
		),
		array(
			"nom" => "pêche",
			"couleur" => "orange",
			"prix" => "4,50"
		),
		array(
			"nom" => "banane",
			"couleur" => "jaune",
			"prix" => "5,50"
		)
	),
	"légume" => array(
		array(
			"nom" => "carotte",
			"couleur" => "orange",
			"prix" => "1,50"
		),
		array(
			"nom" => "haricot",
			"couleur" => "vert",
			"prix" => "2,50"
		)
	)
);

ou comme ceci ?
$data = array(
	array(
		"type" => "fruit",
		"nom" => "fraise",
		"couleur" => "rouge",
		"prix" => "5,50"
	),
	array(
		"type" => "fruit",
		"nom" => "pêche",
		"couleur" => "orange",
		"prix" => "4,50"
	),
	array(
		"type" => "fruit",
		"nom" => "banane",
		"couleur" => "jaune",
		"prix" => "5,50"
	),
	array(
		"type" => "légume",
		"nom" => "carotte",
		"couleur" => "orange",
		"prix" => "1,50"
	),
	array(
		"type" => "légume",
		"nom" => "haricot",
		"couleur" => "vert",
		"prix" => "2,50"
	)
);

tm
$data = array(
	"fruit" => array(
		array(
			"nom" => "fraise",
			"couleur" => "rouge",
			"prix" => "5,50"
		),
		array(
			"nom" => "pêche",
			"couleur" => "orange",
			"prix" => "4,50"
		),
		array(
			"nom" => "banane",
			"couleur" => "jaune",
			"prix" => "5,50"
		)
	),
	"légume" => array(
		array(
			"nom" => "carotte",
			"couleur" => "orange",
			"prix" => "1,50"
		),
		array(
			"nom" => "haricot",
			"couleur" => "vert",
			"prix" => "2,50"
		)
	)
);


Plutôt ceci merci de ta réponse rapide
Modifié par Erewen (01 Feb 2013 - 09:34)
Si tu pouvez m'inclure un exemple de requête quand tu postera un exemple sa serai cool, merci d'avance.