0
「Toutes lescatégories」からこのテーブルをリストするにはどうすればよいですか?アルファベット順ではない配列を並べ替える
<?php
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "\n";
}
//fruits[0] = apple
//fruits[1] = banana
//fruits[2] = lemon
//fruits[3] = orange
?>
この機能のための小さなINT: 以下のコードは、あなたが
sort (array)
などを使用することができます "アニマル・デ・カンパニー" で始まるテーブル...
public function __category_nice_name($categ_name) {
$ret = $categ_name;
$special = array('AllCategories' => '`Toutes les catégories`', 'MP3Downloads' => 'Téléchargements MP3', 'PCHardware' => 'Matériel informatique', 'VHS' => 'VHS', 'Apparel' => 'Habillement', 'Appliances' => 'Électroménager', 'Automotive' => 'Automobile', 'Beauty' => 'Beauté', 'Baby' => 'Bébé', 'Books' => 'Livres', 'Classical' => 'Classique', 'Electronics' => 'Électronique', 'ForeignBooks' => 'Livres étrangères', 'Grocery' => 'Nourriture', 'HomeGarden' => 'Loisirs, Maison & Jardin', 'Jewelry' => 'Bijoux', 'Kitchen' => 'Cuisine', 'Lighting' => 'Éclairage', 'Luggage' => 'Valises et Sacs de voyage', 'Magazines' => 'Magazine', 'MusicalInstruments' => 'Equipement DJ et VJ', 'OfficeProducts' => 'Fournitures scolaires et de bureau', 'OutdoorLiving' => 'Outdoor', 'Outlet' => 'Sale', 'PetSupplies' => 'Animal de compagnie', 'Shoes' => 'Chaussures', 'SportingGoods' => 'Sports & Loisirs', 'Tools' => 'Outils', 'Toys' => 'Jouets', 'Watches' => 'Montres');
if (!in_array($categ_name, array_keys($special))) {
$ret = preg_replace('/([A-Z])/', ' $1', $categ_name);
} else {
$ret = $special["$categ_name"];
}
return $ret;
}