Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8a95615

Browse files
committed
Adding new directory with exercises
1 parent e6cf9ee commit 8a95615

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
4+
$numbers = [
5+
1789, 2035, 1899, 1456, 2013,
6+
1458, 2458, 1254, 1472, 2365,
7+
1456, 2165, 1457, 2456
8+
];
9+
10+
echo "Original numeric array: " . PHP_EOL;
11+
12+
foreach ($numbers as $number) {
13+
echo "$number, ";
14+
}
15+
16+
echo '' . PHP_EOL;
17+
18+
19+
asort($numbers);
20+
echo "Sorted numeric array: " . PHP_EOL;
21+
foreach ($numbers as $number) {
22+
23+
echo "$number, ";
24+
}
25+
echo '' . PHP_EOL;
26+
27+
$words = [
28+
"Java",
29+
"Python",
30+
"PHP",
31+
"C#",
32+
"C Programming",
33+
"C++"
34+
];
35+
36+
37+
echo "Original string array: " . PHP_EOL;
38+
39+
foreach ($words as $word) {
40+
41+
echo "$word, ";
42+
}
43+
44+
echo '' . PHP_EOL;
45+
46+
asort($words);
47+
echo "Sorted string array: " . PHP_EOL;
48+
foreach ($words as $word) {
49+
50+
echo "$word, ";
51+
}
52+
53+
?>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$numbers = [20, 30, 25, 35, -16, 60, -100];
4+
5+
$sum = 0;
6+
foreach ($numbers as $number) {
7+
$sum += $number;
8+
}
9+
10+
$avr = $sum / count($numbers);
11+
12+
echo "Average value: $avr" . PHP_EOL;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$numbers = [
4+
1789, 2035, 1899, 1456, 2013,
5+
1458, 2458, 1254, 1472, 2365,
6+
1456, 2265, 1457, 2456
7+
];
8+
9+
do {
10+
11+
echo "\nEnter the value to search for:\n";
12+
$check = readline("> ") . PHP_EOL;
13+
14+
15+
if (in_array ($check, $numbers)) {
16+
echo "Correct! This value contains in array: $check GOOD JOB!" . PHP_EOL;
17+
break;
18+
} else {
19+
echo "Wrong, this value doesn't not contain number in array! Please try again!" . PHP_EOL;
20+
}
21+
} while ($check !== $numbers );

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /