Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week 2 Assignment #16

Open
wants to merge 1 commit into
base: week_2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions oni_emmanuel/associative.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
//array of 5 top favorite football players and their jersey number
$players =[
//"Emmannuel FC" => [
// "Favourite Players" => [
"Mohammed Salah" =>[
"Jersey No" => 11,
],
"Roberto Firminho" =>[
"Jersey No" => 9,
],
"Sadio Mane" =>[
"Jersey No" => 10,
],
"Virgil Van Dirk" =>[
"Jersey No" => 4,
],
"Alexander Trent-Arnord" =>[
"Jersey No" => 44,
],
//],
//],
];

//sorting Ascending
asort($players);
print_r($players);
echo "<br><br><br>";


//sorting Descending
ksort($players);
print_r($players);

?>
27 changes: 27 additions & 0 deletions oni_emmanuel/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
$space = "<br><br><br>";

//1. creating an array of multiples of 5
$multipleOfFive = range(125, 800, 5);

//2. printing of multiples of 5
print_r($multipleOfFive);
echo $space;

//3. printing numbers from their index values.
echo "The 17th item is " .$multipleOfFive[16]. ", and the 23rd item is " .$multipleOfFive[22]. ", and the 48th item is " .$multipleOfFive[47];
echo $space;

// 4. Echo the number of elements in the array.
echo count($multipleOfFive);
echo $space;

//5. Sum of elements in the array
echo array_sum($multipleOfFive);
echo $space;

//6. Shuffling and printing of the array
shuffle($multipleOfFive);
echo "The 17th item is " .$multipleOfFive[16]. ", and the 23rd item is " .$multipleOfFive[22]. ", and the 48th item is " .$multipleOfFive[47];
echo $space;
?>