caute google mi nepomohol
$mesta = array('New York' => '8175133',
'Los Angeles' => "3792621",
'Chicagoa' => "2695598",
'Houston' => "2100263",
'Philadelphia' => "1526006",
'Phoenix' => "1445632",
'San Diego' => "1307402",
'Dallas' => "1197816",
'San Jose' => "945942");
ako pristupim ku zoradeniu podla hodnoty ?
Resp. ako sa dostanem do tej hodnoty ?
toto je moj vyplod fantazie:
foreach ($mesta as $key => $value) {
SORT_NUMERIC $value; print "$mesta ma $value obyvatelov"
}
Dakujem
zoradit 2rozmerne pole podla hodnoty
- JurajSlovakID
- Používateľ
- Príspevky: 838
- Dátum registrácie: Po 13. Apr, 2015, 09:35
- Bydlisko: Spišská Nová Ves
zoradit 2rozmerne pole podla hodnoty
PC: CPU: RYZEN 5950X VMR-B2@ 4725MHz 1.35V , Chladic Arctic Liquid Freezer II RAM: GSKILL NEO 2x16KIT(32GB) 14-15-15-12-26-38 CR2 - upravene tercialne casovania, GFX: AMD Vega64, MB: Asus Dark Hero VIII X570, M.2 SSD Samsung 990 PRO 2TB, 2xRAID1 WDGOLD 8TB
- Hexaris
- Sponzor fóra gold
- Príspevky: 806
- Dátum registrácie: Št 11. Júl, 2019, 19:35
- Bydlisko: Nekde na zahori
Re: zoradit 2rozmerne pole podla hodnoty
https://www.w3schools.com/php/php_arrays_sort.asp
Pre teba je pouzitelne asort na zaklade hodnoty …
Pre teba je pouzitelne asort na zaklade hodnoty …
Your value does not decrease because of someone's inability to see your worth.
BOOK: MB Air M1 2020 AMP: Topping DX3Pro+ HEADPHONES: HiFiMAN HE400SE
BOOK: MB Air M1 2020 AMP: Topping DX3Pro+ HEADPHONES: HiFiMAN HE400SE
- lepermessiah
- Sponzor fóra gold
- Príspevky: 2796
- Dátum registrácie: Št 30. Dec, 2010, 02:41
- Bydlisko: ZV
Re: zoradit 2rozmerne pole podla hodnoty
a kde je to dvojrozmerne pole? ja vidim jednoduche pole
Spoiler: ukázať
Re: zoradit 2rozmerne pole podla hodnoty
Ja tam zase vidím asocitatívne pole
Cpu:Intel Core i7 2600k @ 4.5Ghz 1.38v
Mb:Asus P8P67 Pro Rev.1
Cpu Cooler:Colink Corator Ds
Gpu:MSI Nvidia Geforce Gtx 670 PE
Ram:Corsair Vegeance 2x4gb
Psu:Aurum Series AU700
Mb:Asus P8P67 Pro Rev.1
Cpu Cooler:Colink Corator Ds
Gpu:MSI Nvidia Geforce Gtx 670 PE
Ram:Corsair Vegeance 2x4gb
Psu:Aurum Series AU700
- JurajSlovakID
- Používateľ
- Príspevky: 838
- Dátum registrácie: Po 13. Apr, 2015, 09:35
- Bydlisko: Spišská Nová Ves
Re: zoradit 2rozmerne pole podla hodnoty
$mesta = array('New York' => '8175133',
'Los Angeles' => "3792621",
'Chicagoa' => "2695598",
'Houston' => "2100263",
'Philadelphia' => "1526006",
'Phoenix' => "1445632",
'San Diego' => "1307402",
'Dallas' => "1197816",
'San Jose' => "945942");
asort($mesta);
foreach ($mesta as $key => $value) {
print "$key ma $value obyvatelov<br>";
}
takto to ide, ok sory som myslel ze toto je viacrozmerne lebo niekde pritom je v knihe kapitola o viacrozmernych poliach
tu je priklad:
$meals = array('breakfast' => ['Walnut Bun','Coffee'],
'lunch' => ['Cashew Nuts', 'White Mushrooms'],
'snack' => ['Dried Mulberries','Salted Sesame Crab']);
$lunches = [['Chicken','Eggplant','Rice'],
['Beef','Scallions','Noodles'],
['Eggplant','Tofu']];
$flavors = array('Japanese' => array('hot' => 'wasabi',
'salty' => 'hot sauce'),
'Chinese' => array('hot' => 'mustard',
'pepper-salty' => 'pricky ash'));
print $meals['lunch'][1];
print $meals['snack'][0];
print $lunches[0][0];
print $lunches[2][1];
print $flavors['Japanese']['salty'];
print $flavors['Chinese']['hot'];
'Los Angeles' => "3792621",
'Chicagoa' => "2695598",
'Houston' => "2100263",
'Philadelphia' => "1526006",
'Phoenix' => "1445632",
'San Diego' => "1307402",
'Dallas' => "1197816",
'San Jose' => "945942");
asort($mesta);
foreach ($mesta as $key => $value) {
print "$key ma $value obyvatelov<br>";
}
takto to ide, ok sory som myslel ze toto je viacrozmerne lebo niekde pritom je v knihe kapitola o viacrozmernych poliach
tu je priklad:
$meals = array('breakfast' => ['Walnut Bun','Coffee'],
'lunch' => ['Cashew Nuts', 'White Mushrooms'],
'snack' => ['Dried Mulberries','Salted Sesame Crab']);
$lunches = [['Chicken','Eggplant','Rice'],
['Beef','Scallions','Noodles'],
['Eggplant','Tofu']];
$flavors = array('Japanese' => array('hot' => 'wasabi',
'salty' => 'hot sauce'),
'Chinese' => array('hot' => 'mustard',
'pepper-salty' => 'pricky ash'));
print $meals['lunch'][1];
print $meals['snack'][0];
print $lunches[0][0];
print $lunches[2][1];
print $flavors['Japanese']['salty'];
print $flavors['Chinese']['hot'];
PC: CPU: RYZEN 5950X VMR-B2@ 4725MHz 1.35V , Chladic Arctic Liquid Freezer II RAM: GSKILL NEO 2x16KIT(32GB) 14-15-15-12-26-38 CR2 - upravene tercialne casovania, GFX: AMD Vega64, MB: Asus Dark Hero VIII X570, M.2 SSD Samsung 990 PRO 2TB, 2xRAID1 WDGOLD 8TB