Skip to content

Solution: Pau Tomás #60

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

Open
wants to merge 3 commits 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
37 changes: 37 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

$arrayString = array("uno","dos","cuatro","cinco");
print_r($arrayString);
echo "<br>";

$arrayNumbers = array(1,2,4,5);
$arrayNumbers2 = array(5,2,2,2);
print_r($arrayNumbers);
echo "<br>";

$arrayMultidimentsional = array(1,array(9,8,7),4,5.3);
print_r($arrayMultidimentsional);
echo "<br>";

echo count($arrayMultidimentsional);
echo "<br>";

print_r(array_merge($arrayString,$arrayNumbers));
echo "<br>";
print_r(array_combine($arrayString,$arrayNumbers));
echo "<br>";
print_r(array_intersect($arrayNumbers2,$arrayNumbers));
echo "<br>";
print_r(array_diff($arrayNumbers2,$arrayNumbers));
echo "<br>";
// print_r(array_count_values($arrayNumbers2,$arrayNumbers));
// echo "<br>";

print_r(end($arrayNumbers));
echo "<br>";

array_push($arrayNumbers,8);
print_r($arrayNumbers);
echo "<br>";

?>
44 changes: 44 additions & 0 deletions conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
$date = date("w");

if ($date == 1 ) {
echo "We are on Monday";
}

$dateMonth = new dateTime("NOW");


if ($dateMonth -> format("M") == "Oct"){
echo "We are in October";
}else {
print $dateMonth -> format("M")."<br>";
}

$minute = date("i");

if ($minute < 10 ){
echo "The current minute is less than 10"."<br>";
}else if ($minute > 15 ){
echo "the current minute is more than 15"."<br>";
}else{
echo "does not meet any conditions"."<br>";
}

$dayWeek = date("w");

switch ($dayWeek) {
case 0:
echo "Monday"."<br>";
break;
case 1:
echo "Tuesday"."<br>";
break;
case 2:
echo "Wednesday"."<br>";
break;
case 3:
echo "Thursday"."<br>";
break;
}

?>
9 changes: 9 additions & 0 deletions dates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$fecha = new DateTime("NOW");
echo $fecha -> format('Y-m-d')."<br>";
echo $fecha -> format('d')."<br>";
echo $fecha -> format('m')."<br>";
echo $fecha -> format('i')."<br>";

?>
50 changes: 50 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

function suma($arg_1,$arg_2){
echo "Funcion de ejemplo";
return print($arg_1 + $arg_2);
}

suma(3,5);
echo "<br>";

function plus($arg_1,$arg_2){
echo "Funcion de ejemplo";
return print($arg_1 * $arg_2);
}

plus(2,5)
echo "<br>";

function div($arg_1,$arg_2){
echo "Funcion de ejemplo";
return print($arg_1 / $arg_2);
}

div(30,2);
echo "<br>";


function multi($arg_1,$arg_2,$variable){
switch ($variable) {
case 'suma':
suma($arg_1,$arg_2);
break;
case 'plus':
plus($arg_1,$arg_2);
break;
case 'div':
div($arg_1,$arg_2);
break;
}
return $arg_1 / $arg_2;
}

multi (1,2,"suma");
echo "<br>";
multi (5,2,"plus");
echo "<br>";
multi (10,2,"div");
echo "<br>";

?>
33 changes: 33 additions & 0 deletions iterators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

//for

for($alphabet = "A"; $alphabet != "AA"; $alphabet++) {
echo $alphabet . " ";
} // This loop shows us the entire alphabet.

echo "<hr>";

$numeros = array (1,2,3,4);

foreach ($numeros as &$value)

print "the number is: $value <br>";

$x=0;
while ($x < 10){
print "the number is $x <br>";
$x++;
}

echo "<hr>";

$y=10;
do{
print "the number is $y <br>";
$y--;
}
while($y > 0);


?>
9 changes: 9 additions & 0 deletions maths.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
echo(abs(-6.7) . "<br>");
echo(ceil(6.3) . "<br>");
echo(max(6.3,5,4,20) . "<br>");
echo(min(6.3,5,4,20) . "<br>");
echo(rand(2,20) . "<br>");
$random = rand(10,100);
echo$random. "<br>";
?>
73 changes: 73 additions & 0 deletions operators.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

$x = 10;
$y = 6;

echo $x + $y."<br>";
echo $x - $y."<br>";
echo $x * $y."<br>";
echo $x / $y."<br>";
echo $x % $y."<br>";

$a = 20;
$b = 21;

if( $a == $b ) {
echo "a and b is equal<br>";
}else {
echo "a is not equal to b <br>";
}
if( $a === $b ) {
echo "a and b is equal<br>";
}else {
echo "a is not equal to b<br>";
}
if( $a != $b ) {
echo "a and b is diferent<br>";
}else {
echo "a is equal to b<br>";
}
if( $a < $b ) {
echo "a is smaller than b <br>";
}else {
echo "b is smaller than a <br>";
}
if( $a > $b ) {
echo "a is bigger than b <br>";
}else {
echo "b is bigger than a <br>";
}
if( $a <= $b ) {
echo "a is smaller or equal than b <br>";
}else {
echo "b is smaller or equal than a <br>";
}
if( $a >= $b ) {
echo "a is bigger or equal than b <br>";
}else {
echo "b is bigger or equal than a <br>";
}
if ($x == 10 and $y == 6) {
echo "Hello world! <br>";
}
if ($x == 10 && $y == 6) {
echo "Hello world! <br>";
}
if ($x == 10 || $y == 5) {
echo "Hello world! <br>";
}
if ($x == 10 or $y == 5) {
echo "Hello world! <br>";
}
if ($x == 10 && $y == 6) {
echo "Hello world! && <br>";
}
if (! ($x==9) ) {
echo "Hello world! water <br>";
}
if ($x == 10 xor $y == 5) {
echo "Hello world! xor <br>";
}


?>
3 changes: 3 additions & 0 deletions phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
phpinfo();
?>
45 changes: 45 additions & 0 deletions print.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

//Instruction that makes use of "echo"

echo "This is a test with echo.", "\n", "<br>"; // "\n" means line feed (avance de línea)

echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', "\n", "<br>";

echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n" . "<br>"; // . is used to concatenate

echo "Hello ", isset($name) ? $name : "Pau Tomás", "!" , "<br>";

$example = "The argument can be any expression";
echo "$example which produces a string", "<br>";

$sports = ["tenis", "padel", "football", "basketball"];
echo "My favourite sports are " . implode(", ", $sports) . "..." . "<br>"; // implode — Join array elements with a string

echo 3 * 12;
echo "<hr>";

//Instruction that makes ude of "print"

print "This is a test with print. <br>";

$example = "The argument can be any expression";
print "$example which produces a string <br>";

$sports = ["tenis", "padel", "football", "basketball"];
print implode(", ", $sports);

print "<br>";
print 6 * 7;
print "<hr>";


//Instruction that makes use of "print_r" — Prints human-readable information about a variable

echo "<pre>";
$a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));

print_r ($a);
echo "</pre>";

?>
31 changes: 31 additions & 0 deletions strings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
echo "Hello\n";

$world = "World!\n";
echo "$world";

echo "Hello $world\n";

$cat = "Cat\n";
echo str_ireplace("c", "b", $cat);

echo str_replace("C", "b", $cat);

$hello = "Hello";
echo str_repeat($hello . "\n", 5);

$length = "length\n";
echo strlen($length);

$str = "hello\n";
echo strpos($str, "o");

echo ucfirst($str);

$strToLow = "Hello\n";
echo strtolower($strToLow);

$text = "Hello, how are you?";
$find = substr($text, 7, 3);
echo $find;
?>
Loading