Skip to content
GitLab
Menu
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Edin Skoko
BrainsterChallenges_EdinSkokoFS16
Commits
b1ddacd8
Commit
b1ddacd8
authored
1 year ago
by
Edin Skoko
Browse files
Options
Download
Email Patches
Plain Diff
added challenge 11 to git
parent
8b7ff0b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Challenge11.php
+109
-0
Challenge11.php
with
109 additions
and
0 deletions
+109
-0
Challenge11.php
0 → 100644
+
109
-
0
View file @
b1ddacd8
<?php
$name
=
"Kathrin"
;
if
(
$name
==
"Kathrin"
)
{
echo
"Hello Kathrin"
;
}
else
{
echo
"Nice name"
;
}
echo
"<br>"
;
$rating
=
5
;
if
(
$rating
>=
1
&&
$rating
<=
10
)
{
echo
"Thank you for rating"
;
}
else
{
echo
'Invalid rating, only numbers between 1 and 10'
;
}
echo
"<br>"
;
echo
"<hr>"
;
$time
=
date
(
"H"
);
if
(
$time
<
12
)
{
echo
"Good morning
$name
"
;
}
elseif
(
$time
<
19
)
{
echo
"Good afternoon
$name
"
;
}
else
{
echo
"Good evening
$name
"
;
}
echo
"<br>"
;
$rated
=
true
;
if
(
$rating
>=
1
&&
$rating
<=
10
)
if
(
$rated
==
true
)
{
echo
"You already voted"
;
}
else
{
echo
"Thanks for voting"
;
}
echo
"<br>"
;
var_dump
(
$rating
);
echo
"<br>"
;
echo
"<hr>"
;
$votes
=
[
'Marija'
=>
"true, 1"
,
'Edin'
=>
"false, 8"
,
'Nikola'
=>
"false, 4"
,
'Stefan'
=>
"true, 12"
,
'Omer'
=>
"false, 5"
,
'Ana'
=>
"true, 2"
,
'Ena'
=>
"false, 7"
,
'Leo'
=>
"true, 7"
,
'Ahmed'
=>
"false, 11"
,
'Tanja'
=>
"true, 10"
,
];
foreach
(
$votes
as
$voter
=>
$value
)
{
list
(
$voted
,
$rating
)
=
explode
(
','
,
$value
);
if
(
$voted
==
"true"
&&
$rating
>=
1
&&
$rating
<=
10
)
{
$message
=
"Thanks for voting with
$rating
"
;
}
elseif
(
$voted
==
"false"
&&
$rating
>=
1
&&
$rating
<=
10
)
{
$message
=
"You already voted with
$rating
."
;
}
else
{
$message
=
"Invalid rating, only numbers between 1 and 10."
;
}
echo
"
$voter
=>
$value
<br>"
;
if
(
$time
<
12
)
{
echo
"Good morning
$voter
,<br>
$message
<br> <br>"
;
}
elseif
(
$time
<
19
)
{
echo
"Good afternoon
$voter
,<br>
$message
<br> <br>"
;
}
else
{
echo
"Good evening
$voter
,<br>
$message
<br> <br>"
;
}
}
?>
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets