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 Kenny Naranjo #82

Open
wants to merge 2 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
39 changes: 39 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
$manga = array("Op, Zatch bell, Konosuba");
print_r($manga);
echo "<br><br>";

$numbers = array (5, 6, 4.2, 2.14);
print_r($numbers);
echo "<br><br>";
$gaming = array (
array("Ps5",16,19),
array("NSwtich",17,12),
array("XboxScorpion",4,1),
array("Wii",20,12)
);

echo $gaming[0][0].": In stock: ".$gaming[0][1].", sold: ".$gaming[0][2].".<br>";
echo $gaming[1][0].": In stock: ".$gaming[1][1].", sold: ".$gaming[1][2].".<br>";
echo $gaming[2][0].": In stock: ".$gaming[2][1].", sold: ".$gaming[2][2].".<br>";
echo $gaming[3][0].": In stock: ".$gaming[3][1].", sold: ".$gaming[3][2].".<br>";
echo "<br><br>";
$candys = array("sugar","gumis","trince", "palet");
echo count($candys);
echo "<br><br>";
$k = array('green', 'red', 'yellow');
$l = array('hulk', 'sanji', 'sukuna');
$mix = array_combine($k, $l);
print_r($mix);
echo "<br><br>";
$letters = array('a', 'b', 'c','d', 'e', 'f');
echo end($letters);
echo "<br><br>";
$fruitsM = array("banana", "avocado", "apple");
array_push($fruitsM, "blueberry", "strawberry");
print_r($fruitsM);




?>
60 changes: 60 additions & 0 deletions conditionals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
#We are on Monday
$today = "Mon";
if(date("D") == $today){
echo "We are on Monday";
} else {
echo "Today is not Monday";
}
echo "<br><br>";
#We are in October

$t = "October";
if(date("F") == $t){
echo "We are on October";
} else{
echo "We are on&nbsp", date("F");
}

echo "<br><br>";

#Double condition
if(date("i") < 10){
echo "the current minute is less 10";
}
else if(date("i") > 15){
echo "the currente minute is more than 15";
}
else{
echo "does not meet any condition";
}
echo "<br><br>";

#Switch
$dia = date("D");

switch($dia){
case 'Mon':
echo "Today is monday";
break;
case 'Tue':
echo "Today is tuesday";
break;
case 'wed':
echo "Today is wednesday";
break;
case 'thu':
echo "Today is thusday";
break;
case 'fri':
echo "Today is friday";
break;
case 'sat':
echo "Today is satuday";
break;
case 'sun':
echo "Today is sunday";
break;

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

echo date("Y.m.d");

echo "<br><br>";

echo date(DATE_RFC2822);

echo "<br><br>";

echo date ("l");

echo "<br><br>";

echo date ("m");

echo "<br><br>";

echo date ("i");




?>
37 changes: 37 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
#FUNCTION
function addTwoNumbers($x, $y)
{
return $x + $y;
}

echo " sum of 10 and 25 : " . addTwoNumbers(10, 25);
echo "<br>";
function addmulti($x, $y)
{
return $x * $y;
}

echo " mult of 10 and 25 : " . addmulti(10, 25);
echo "<br>";
function addiv($x, $y)
{
return $x / $y;
}

echo " div of 10 and 25 : " . addiv(10, 25);

echo "<br>";
function operation($x, $y, $operation){
if ($operation == "add"){
return $x + $y;
} else if ($operation == "multiply"){
return $x * $y;
}
}
echo operation(10, 25, "add");
echo "<br";
echo operation(10, 25, "multiply");


?>
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($i = 3; $i <=9; $i++){
echo $i;
}
echo "<br><br>";
#foreach

$a = array(1, 2, 3, 4);
foreach ($a as $k){
echo "Valor actual de $k ";
}
echo "<br><br>";

#while
$l = 1;
while($l <=5){
echo $l;
$l++;
}
echo "<br><br>";

#do while
$k = 5;
do{
echo $k;
$k++;
}
while($k <= 10);
echo "<br><br>";

?>
22 changes: 22 additions & 0 deletions maths.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
#absolute value
$a = 10;
$b = 5.8;
var_dump(abs($a - $b));
var_dump(abs($a - 5));
echo "<br><br>";
#rounded
var_dump(round($a - 1.5));
var_dump(round($b - $a));
echo "<br><br>";
#highest value
echo "this is highest&nbsp", max($a, $b, -15, -50, -300);
echo "<br><br>";
#lowest value
echo "this is lowest&nbsp", min($a, $b, 15, 50, 300);
echo "<br><br>";

#random number
echo rand($a, $b);

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

$a = 5;
$b = 6;
var_dump($a + $b, $a - $b, $a * $b, $a / $b, $a % $b);
echo "<br><br>";

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

var_dump($a && $b, $a and $b, $a || $b, $a or $b, $a != $b, $a Xor $b);




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





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

echo "hola Assembler<br>", "vamor a perder como Francia<br>";
print "Argentina ganadora<br>";

$a = array('a'=> 'luffy', 'b'=>'zoro', 'c'=> array ('x', 'y', 'z'));
print_r($a['c']);


?>
36 changes: 36 additions & 0 deletions strings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
print "Print a text string<br>";

$a = "Print a text string";
print $a."two";
echo "<br><br>";

#case sensitive
$phrase = "Monkey D Luffy is our captain";

echo str_replace("Monkey D Luffy", "Yonkou strawhat", $phrase);

echo "<br><br>";
#without taking into account upper / lower case
$king = "Mamodo rules is a king";

echo str_ireplace("mamodo RULES", "Zatch", $king);
echo "<br><br>";
$dance = "\OwO/";
echo str_repeat($dance, 10);
echo "<br><br>";
$w = 'wzr e s x r d cf tv g y b u h n j i m';
echo strlen($w);
echo "<br><br>";
$thinks = "twegdfj dos dfhsf";
echo strpos($thinks,'dos');
echo "<br><br>";
$mary = "When i go to the bar, i like eat macarroni";
echo strtoupper($mary);
echo "<br><br>";
$marydo = "I HATE THIS GAME, IS SO DISGUSTING";
echo strtolower($marydo);
echo "<br><br>";
$paco = "a paco le gusta el queso";
echo substr($paco, 4, -2);
?>
40 changes: 40 additions & 0 deletions types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
#boolean
$a = "cosa";
$b = "linda";

var_dump($a);
var_dump($b);

echo "<br><br>";
#integer
$a = 10;
var_dump($a);



echo "<br><br>";
#floats
$a = 4.70;
var_dump($a);

echo "<br><br>";

#string
$str = "Scoobido papa";
var_dump($str);
echo "<br><br>";
#array
$array = array('ussop', 'sanji', 'chopper', 'nami');
var_dump($array);
echo "<br><br>";
#object
$yonkou = (object)["yonkou1"=>"Shanks","yonkou2"=>"Kurohige","yonkou3"=>"Luffy"];
echo "This is a emperors of sea: $yonkou->yonkou3<br>";
var_dump($yonkou);
echo "<br><br>";
#null
$text = 'Hello darkness my old friend';
$text = null;
var_dump($text);
?>