Splicing av arrays i PHP
array_spliceЗадание 1
Gitt array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Klipp ut elementer fra den, så arrayet blir slik:
php<?php
[1, 4, 5]
?>
Задание 2
Gitt array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Hent følgende utsnitt fra dette arrayet:
php<?php
[2, 3, 4]
?>
Задание 3
Gitt array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Legg til nye elementer i dette arrayet:
php<?php
[1, 2, 3, 'a', 'b', 'c', 4, 5]
?>
Задание 4
Gitt array:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Legg til nye elementer i dette arrayet:
php<?php
[1, 'a', 'b', 2, 3, 4, 'c', 5, 'e']
?>