Splicing af arrays i PHP
array_spliceЗадание 1
Givet et array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Udskær elementer fra det, så arrayet bliver sådan her:
php<?php
[1, 4, 5]
?>
Задание 2
Givet et array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Uddrag følgende udsnit fra dette array:
php<?php
[2, 3, 4]
?>
Задание 3
Givet et array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Tilføj nye elementer til dette array:
php<?php
[1, 2, 3, 'a', 'b', 'c', 4, 5]
?>
Задание 4
Givet et array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Tilføj nye elementer til dette array:
php<?php
[1, 'a', 'b', 2, 3, 4, 'c', 5, 'e']
?>