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

Solution: Sofía Romera #55

Open
wants to merge 1 commit into
base: master
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
54 changes: 54 additions & 0 deletions Functionalities/arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arrays</title>
</head>
<body>
<!--
Define a simple array composed of text strings
Define a simple array consisting of whole numbers and decimal numbers
Define a multidimensional array
Execute the function that allows to obtain the length of an array
Execute the function that allows to obtain the combination of two arrays
Execute the function that once is given an array return the last element of it
Execute the function that once is given an array add a new element to the array in question
-->
<?php
$simpleArray = array('Hyoyeon', 'Taeyeon', 'Tiffany');
var_dump($simpleArray);
echo '<br>';

$simpleArray2 = array(11, 30, 30.15, 1.14159265);
var_dump($simpleArray2);
echo '<br>';

$bts = array(
array('RM'),
array('Jin'),
array('Taehyung'),
array('Jimin'),
array('Suga'),
array('J-Hope'),
array('Jungkook')
);
var_dump($bts);
echo '<br>';

echo count($simpleArray);
echo '<br>';

$comb = array_merge($simpleArray, $bts);
var_dump($comb);
echo '<br>';

$pushArray = array('Rose Quartz, Amethyst', 'Tiger Eye');
array_push($pushArray, 'Citrine');
var_dump($pushArray);

?>

</body>
</html>
69 changes: 69 additions & 0 deletions Functionalities/conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Conditionals</title>
</head>
<body>
<!--
Create a simple condition that evaluates whether the current day is Monday. Only in the case that the condition is met, it shows a message of “We are on Monday”.
Create a simple condition that evaluates whether the current month is October. If the condition is met, it shows a message of the type "We are in October". Otherwise, if this condition is not met, show the current month in words as it come from DateTime.
Create a double condition that evaluates:
If the current minute is less than 10. Displays a message of type "the current minute is less than 10", if the current minute is greater than 15, displays a message of the type "the current minute is more than 15". If you do not meet any of the two conditions above: Displays a message of the type "does not meet any conditions”
Create a switch type control structure to display a different message depending on the current day of the week. You can write any type of message, because the important thing is that you understand how it works and in what cases you can use it.
-->
<?php

if (date('D') == "Mon")
echo "We are on monday";

echo '<br><br>';

if (date('M') == "Oct"){
echo "We are on October!!";
}else{
echo date('M');
}

echo '<br><br>';

if(date('i') < 10){
echo "the current minute is less than 10";
}elseif (date('i') > 15) {
echo "the current minute is more than 15";
}else {
echo "does not meet any conditions";
}

echo "<br>";
echo "<br>";

$dt = date('D');
switch ($dt) {
case "Mon":
echo "Today is: $dt";
break;
case "Tue":
echo "Today is: $dt";
break;
case "Wed":
echo "Today is: $dt";
break;
case "Thu":
echo "Today is: $dt";
break;
case "Fri":
echo "Today is: $dt";
break;
case "Sat":
echo "Today is: $dt";
break;
case "Sun":
echo "Today is: $dt";
break;
}
?>
</body>
</html>
28 changes: 28 additions & 0 deletions Functionalities/dates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Date</title>
</head>
<body>
<!--
Instance the Date Time class and then invoke the format method with the argument “Y-m-d” to show year-month-day
Get the current date in any format
Get the current day
Get the current month in numerical format (1-12)
Get the current minute with leading zeros (00 - 59)
-->
<?php
$dt = date("d/m/y");
echo $dt . "<br>";
echo "Today is " . date("d") . "<br>";
echo "Month is: " . intval(date("m")) . "<br>"; //intval to remove the zero
echo "Today is " . date("l") . "<br>";
echo "Time: " . date("h:i:s") . "<br>";
echo "Minute: " . date("i");

?>
</body>
</html>
50 changes: 50 additions & 0 deletions Functionalities/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Functions</title>
</head>
<body>
<!--
This file will be used to store your first tests regarding the implementation of functions:
Create a function that given two numbers returns the sum of both
Create a function that given two numbers returns the multiplication of both
Create a function that given two numbers returns the division of both
Create a function that, given two numbers and an operation (add, multiply or divide), returns the result of that operation.
Depending on the type of operation received by parameter, the function will execute the function responsible for performing the operation, since you have previously implemented the function for each operation separately.
-->
<?php
function sum($a, $b) {
echo $a + $b;
}
sum(23, 9);
echo '<br>';

function mult($a, $b) {
echo $a * $b;
}
mult(3, 2);
echo '<br>';

function divs($a, $b) {
echo $a / $b;
}
divs(6, 2);
echo '<br>';

function op($a, $op, $b ){
if ($op == "+") {
return $a + $b;
}elseif ($op == "*") {
return $a * $b;
}else if ($op == "/") {
return $a / $b;
}
}
echo op(2, '*', 9);

?>
</body>
</html>
49 changes: 49 additions & 0 deletions Functionalities/iterators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Iterators</title>
</head>
<body>
<!--
Generate a snippet that makes use of for
Generate a snippet that makes use of foreach
Generate a snippet that uses while
Generate a snippet that uses do while
-->
<?php
for ($i=0; $i < 5; $i++) {
echo "<br>* $i";
}

echo '<br>';
echo '<br>';

$nums = array('1', '2', '3', '4', '5');
foreach ($nums as $value) {
echo $value * 2;
}

echo '<br>';
echo '<br>';

$noms = array('pear', 'banana', 'apple');
foreach ($noms as $key) {
echo $key.' is a fruit'.'<br>';
}
echo "<br>";
$i = 0;
while ($i <= 10) {
echo "Num is: $i <br>";
$i++;
}

do{
echo "$i <br>";
} while ($i < 10);
?>

</body>
</html>
41 changes: 41 additions & 0 deletions Functionalities/maths.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Maths</title>
</head>
<body>
<!--
Define a variable whose value is the result of the function that returns an absolute value.
Define a variable whose value is the result of the function that returns a rounded value to the next highest integer.
Define a variable whose value is the result of the function that returns the highest value of a series of values ​​that are received by parameter.
Define a variable whose value is the result of the function that returns the lowest value of a series of values ​​that are received by parameter.
Define a variable whose value is the result of the function that returns a random number
-->
<?php
$a = abs(-2);
echo $a;
echo '<br>';

$b = ceil(3.14159265);
echo $b;
echo '<br>';

$c = max(2, 4, 9, 25, 6, 98, 3);
echo $c;
echo '<br>';

$d = min(2, 4, 9, 25, 6, 98, 3);
echo $d;
echo '<br>';

$e = rand(1, 100);
echo $e;
echo '<br>';

?>

</body>
</html>
78 changes: 78 additions & 0 deletions Functionalities/operators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Operators</title>
</head>
<body>
<!--
Create an example of use for arithmetic operators: +, -, *, /, and%
Create a usage example for comparison operators: ==,! =, <,>, <=,> =
Create an example of use for logical operators: &&, And; ||, Or; ! (NOT); Xor
-->
<?php

$a = array(1, 2, array("a", "b", "c"));
var_dump($a);

$a = 2;
$b = 5;

echo '<br>';
echo '-------';
echo '<br>';

echo ($a + $b);
echo '<br>';
var_dump ($a - $b);
echo '<br>';
var_dump ($a * $b);
echo '<br>';
var_dump (intdiv($a , $b));
echo '<br>';
var_dump ($a % $b);
echo '<br>';

echo '<br>';
echo '-------';
echo '<br>';

//Comparison operators

echo ($a == $b);
echo '<br>';
var_dump ($a != $b);
echo '<br>';
var_dump ($a < $b);
echo '<br>';
var_dump ($a > $b);
echo '<br>';
var_dump ($a <= $b);
echo '<br>';
var_dump ($a >= $b);
echo '<br>';


echo '<br>';
echo '-------';
echo '<br>';

//Logical operators
var_dump ($a && $b);
echo '<br>';
var_dump ($a and $b);
echo '<br>';
var_dump ($a || $b);
echo '<br>';
var_dump ($a or $b);
echo '<br>';
var_dump (! $b);
echo '<br>';
var_dump ($a Xor $b);
echo '<br>';

?>
</body>
</html>
Loading