Nivå 9.8 av PHP-uppgiftsboken
Givet en godtycklig tvådimensionell array:
[
[11, 12, 13, 14, 15],
[21, 22, 23, 24, 25],
[31, 32, 33, 34, 35],
[41, 42, 43, 44, 45],
[51, 52, 53, 54, 55],
]
Byt plats på två givna rader:
[
[51, 52, 53, 54, 55],
[21, 22, 23, 24, 25],
[31, 32, 33, 34, 35],
[41, 42, 43, 44, 45],
[11, 12, 13, 14, 15],
]
Låt det i en fil lagras JSON av länder av följande typ:
{
[
"id": "3",
"country": "country1",
],
[
"id": "7",
"country": "country2",
],
[
"id": "9",
"country": "country3",
]
}
Visa dessa länder i form av följande select:
<select>
<option value="3">country1</option>
<option value="7">country2</option>
<option value="9">country3</option>
</select>