Masīvu splice PHP
array_spliceЗадание 1
Dots masīvs:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Izgrieziet no tā elementus, lai masīvs kļūtu šāds:
php<?php
[1, 4, 5]
?>
Задание 2
Dots masīvs:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Iegūstiet no šī masīva šādu daļu:
php<?php
[2, 3, 4]
?>
Задание 3
Dots masīvs:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Pievienojiet šim masīvam jaunus elementus:
php<?php
[1, 2, 3, 'a', 'b', 'c', 4, 5]
?>
Задание 4
Dots masīvs:
php<?php
$arr = [1, 2, 3, 4, 5];
?>
Pievienojiet šim masīvam jaunus elementus:
php<?php
[1, 'a', 'b', 2, 3, 4, 'c', 5, 'e']
?>