-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShiftingUnshifting.php
More file actions
38 lines (23 loc) · 1023 Bytes
/
ShiftingUnshifting.php
File metadata and controls
38 lines (23 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
$adjectives = ["bad", "good", "great", "fantastic"];
$removed = array_shift($adjectives);
echo $removed; //Prints: bad
echo implode(", ", $adjectives); // Prints: good, great, fantastic
$foods = ["pizza", "crackers", "apples", "carrots"];
$arr_len = array_unshift($foods, "pasta", "meatballs", "lettuce");
echo $arr_len; //Prints: 7
echo implode(", ", $foods);
// Prints: pasta, meatballs, lettuce, pizza, crackers, apples, carrots
$record_holders = [];
// Write your code below:
array_unshift($record_holders, "Tim Montgomery",
"Maurice Greene", "Donovan Bailey", "Leroy Burrell", "Carl Lewis");
echo implode(", ", $record_holders) . "\n\n";
array_shift($record_holders);
echo implode(", ", $record_holders) . "\n\n";
array_unshift($record_holders, "Justin Gatlin", "Asafa Powell");
echo implode(", ", $record_holders) . "\n\n";
array_shift($record_holders);
echo implode(", ", $record_holders) . "\n\n";
array_unshift($record_holders, "Usain Bolt");
echo implode(", ", $record_holders) . "\n\n";