-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.php
More file actions
32 lines (22 loc) · 671 Bytes
/
array.php
File metadata and controls
32 lines (22 loc) · 671 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
<?php
$foods = array("apple", "Orange", "Pineapple", "Mango", "Cherry");
// $foods[0]= 'coconut';
// echo $foods[0].PHP_EOL;
array_push($foods, 'sugarcane', 'kiwi');
foreach ($foods as $food) {
echo $food . PHP_EOL;
}
$popped_array = array_pop($foods);
echo $popped_array . PHP_EOL;
echo '----------------' . PHP_EOL;
foreach ($foods as $food) {
echo $food . PHP_EOL;
}
echo '----------------' . PHP_EOL;
$shifted_array = array_shift($foods);
echo $shifted_array . PHP_EOL; //Shifted works like basically pop.
echo '----------------' . PHP_EOL;
$reversed_foods = array_reverse($foods);
foreach ($reversed_foods as $food) {
echo $food . PHP_EOL;
}