View difference between Paste ID: KcX4wMw0 and dJQRS6UD
SHOW: | | - or go back to the newest paste.
1
<?php
2
	$armurerie= array("epee" => 50, "bouclier" => 35, "armure" => 85, "marteau" => 50, "dague" => 25, "shuriken" => 5);
3
4
	function tri($tab)
5
	{
6-
		foreach ($tab as $key => $value) 
6+
		$key = array_key($tab); //On récupere juste les clée / index /nom
7
		$taille = count($key);
8-
			$taille = count($tab);
8+
		for($i = 1; $i < $taille; $i++)
9-
			for($i = 1; $i < $taille; $i++)
9+
10
			for($j = $taille-2; $j >= $i; $j--)
11-
				for($j = $taille-2; $j >= $i; $j--)
11+
12
				if($tab[$key[$j+1]] < $tab[$key[$j]]) //avant, ici, tu cherchait les index comme des nombre mais $armurerie[0] par exemple, ca n'existe pas, il faut utilisé les clée / nom.
13-
					if($tab[$j+1] < $tab[$j])
13+
14-
					{
14+
					$temp = $tab[$key[$j+1]];
15-
						$temp = $tab[$j+1];
15+
					$tab[$key[$j+1]] = $tab[$key[$j]];
16-
						$tab[$j+1] = $tab[$j];
16+
					$tab[$key[$j]] = $temp;
17-
						$tab[$j] = $temp;
17+
					//La tu vas encore avoir un probleme, mais je te laise cherché
18-
					}
18+
19
			}
20
		}
21
	}
22
23
	tri($armurerie);
24
25
26
	var_dump($armurerie);
27
?>