diff --git a/arrays.php b/arrays.php new file mode 100644 index 0000000..f1e2d0f --- /dev/null +++ b/arrays.php @@ -0,0 +1,39 @@ +
"; + +$numbers = array (5, 6, 4.2, 2.14); +print_r($numbers); +echo "

"; +$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].".
"; + echo $gaming[1][0].": In stock: ".$gaming[1][1].", sold: ".$gaming[1][2].".
"; + echo $gaming[2][0].": In stock: ".$gaming[2][1].", sold: ".$gaming[2][2].".
"; + echo $gaming[3][0].": In stock: ".$gaming[3][1].", sold: ".$gaming[3][2].".
"; +echo "

"; +$candys = array("sugar","gumis","trince", "palet"); +echo count($candys); +echo "

"; +$k = array('green', 'red', 'yellow'); +$l = array('hulk', 'sanji', 'sukuna'); +$mix = array_combine($k, $l); +print_r($mix); +echo "

"; +$letters = array('a', 'b', 'c','d', 'e', 'f'); +echo end($letters); +echo "

"; +$fruitsM = array("banana", "avocado", "apple"); +array_push($fruitsM, "blueberry", "strawberry"); +print_r($fruitsM); + + + + +?> \ No newline at end of file diff --git a/conditionals.php b/conditionals.php new file mode 100644 index 0000000..36e570b --- /dev/null +++ b/conditionals.php @@ -0,0 +1,60 @@ +
"; +#We are in October + +$t = "October"; +if(date("F") == $t){ + echo "We are on October"; +} else{ + echo "We are on ", date("F"); +} + +echo "

"; + +#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 "

"; + +#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; + +} +?> \ No newline at end of file diff --git a/dates.php b/dates.php new file mode 100644 index 0000000..f3c2bdf --- /dev/null +++ b/dates.php @@ -0,0 +1,24 @@ +
"; + +echo date(DATE_RFC2822); + +echo "

"; + +echo date ("l"); + +echo "

"; + +echo date ("m"); + +echo "

"; + +echo date ("i"); + + + + +?> \ No newline at end of file diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..6ad36f1 --- /dev/null +++ b/functions.php @@ -0,0 +1,37 @@ +"; +function addmulti($x, $y) +{ + return $x * $y; +} + +echo " mult of 10 and 25 : " . addmulti(10, 25); +echo "
"; +function addiv($x, $y) +{ + return $x / $y; +} + +echo " div of 10 and 25 : " . addiv(10, 25); + +echo "
"; +function operation($x, $y, $operation){ + if ($operation == "add"){ + return $x + $y; + } else if ($operation == "multiply"){ + return $x * $y; + } +} +echo operation(10, 25, "add"); +echo " \ No newline at end of file diff --git a/iterators.php b/iterators.php new file mode 100644 index 0000000..8945e2f --- /dev/null +++ b/iterators.php @@ -0,0 +1,33 @@ +
"; +#foreach + +$a = array(1, 2, 3, 4); +foreach ($a as $k){ + echo "Valor actual de $k "; +} +echo "

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

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

"; + +?> \ No newline at end of file diff --git a/maths.php b/maths.php new file mode 100644 index 0000000..05aecd9 --- /dev/null +++ b/maths.php @@ -0,0 +1,22 @@ +
"; +#rounded +var_dump(round($a - 1.5)); +var_dump(round($b - $a)); +echo "

"; +#highest value +echo "this is highest ", max($a, $b, -15, -50, -300); +echo "

"; +#lowest value +echo "this is lowest ", min($a, $b, 15, 50, 300); +echo "

"; + +#random number +echo rand($a, $b); + +?> \ No newline at end of file diff --git a/operators.php b/operators.php new file mode 100644 index 0000000..e3433ad --- /dev/null +++ b/operators.php @@ -0,0 +1,16 @@ +
"; + +var_dump($a == $b, $a != $b, $a < $b, $a > $b, $a <= $b, $a >= $b); +echo "

"; + +var_dump($a && $b, $a and $b, $a || $b, $a or $b, $a != $b, $a Xor $b); + + + + +?> \ No newline at end of file diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 0000000..d83f3a6 --- /dev/null +++ b/phpinfo.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/print.php b/print.php new file mode 100644 index 0000000..2693024 --- /dev/null +++ b/print.php @@ -0,0 +1,10 @@ +", "vamor a perder como Francia
"; +print "Argentina ganadora
"; + +$a = array('a'=> 'luffy', 'b'=>'zoro', 'c'=> array ('x', 'y', 'z')); +print_r($a['c']); + + +?> \ No newline at end of file diff --git a/strings.php b/strings.php new file mode 100644 index 0000000..63189b8 --- /dev/null +++ b/strings.php @@ -0,0 +1,36 @@ +"; + +$a = "Print a text string"; +print $a."two"; +echo "

"; + +#case sensitive +$phrase = "Monkey D Luffy is our captain"; + +echo str_replace("Monkey D Luffy", "Yonkou strawhat", $phrase); + +echo "

"; +#without taking into account upper / lower case +$king = "Mamodo rules is a king"; + +echo str_ireplace("mamodo RULES", "Zatch", $king); +echo "

"; +$dance = "\OwO/"; +echo str_repeat($dance, 10); +echo "

"; +$w = 'wzr e s x r d cf tv g y b u h n j i m'; +echo strlen($w); +echo "

"; +$thinks = "twegdfj dos dfhsf"; +echo strpos($thinks,'dos'); +echo "

"; +$mary = "When i go to the bar, i like eat macarroni"; +echo strtoupper($mary); +echo "

"; +$marydo = "I HATE THIS GAME, IS SO DISGUSTING"; +echo strtolower($marydo); +echo "

"; +$paco = "a paco le gusta el queso"; +echo substr($paco, 4, -2); +?> \ No newline at end of file diff --git a/types.php b/types.php new file mode 100644 index 0000000..b2ac4b5 --- /dev/null +++ b/types.php @@ -0,0 +1,40 @@ +
"; +#integer +$a = 10; +var_dump($a); + + + +echo "

"; +#floats +$a = 4.70; +var_dump($a); + +echo "

"; + +#string +$str = "Scoobido papa"; +var_dump($str); +echo "

"; +#array +$array = array('ussop', 'sanji', 'chopper', 'nami'); +var_dump($array); +echo "

"; +#object +$yonkou = (object)["yonkou1"=>"Shanks","yonkou2"=>"Kurohige","yonkou3"=>"Luffy"]; +echo "This is a emperors of sea: $yonkou->yonkou3
"; +var_dump($yonkou); +echo "

"; +#null +$text = 'Hello darkness my old friend'; +$text = null; +var_dump($text); +?> \ No newline at end of file