Nivå 8.4 oppgavesamling for PHP
Задание 1
Når siden besøkes, skriv til sesjonen tidspunktet for brukerens besøk. Etter at siden oppdateres, vis på skjermen tidspunktet for brukerens forrige besøk.
Задание 2
Gitt en bestemt URL:
php$url = 'http://test.com/dir1/dir2/dir3/page.html';
Hent mappene fra den som en array:
php['dir1', 'dir2', 'dir3']
Задание 3
Vis følgende pyramide på skjermen:
1
22
333
4444
55555
666666
7777777
88888888
999999999
22
333
4444
55555
666666
7777777
88888888
999999999
Задание 4
Det gis en liste over byer og deres land, lagret i følgende struktur:
php<?php
$data = [
[
'country' => 'country1',
'city' => 'city11',
],
[
'country' => 'country2',
'city' => 'city21',
],
[
'country' => 'country3',
'city' => 'city31',
],
[
'country' => 'country1',
'city' => 'city12',
],
[
'country' => 'country1',
'city' => 'city13',
],
[
'country' => 'country2',
'city' => 'city22',
],
[
'country' => 'country3',
'city' => 'city31',
],
];
?>
Skriv kode som omstrukturerer dataene til slik:
php[
'country1': [
'city11', 'city12', 'city13',
],
'country2': [
'city21', 'city22'
],
'country3': [
'city31', 'city32'
],
]