Skip to content
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
56 changes: 56 additions & 0 deletions arrays.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
# ARRAY + STRING
print_r (array("Hola", "Como estas", "Adios"));
echo "<br><br>";

# ARRAY + NUMBER + DECIMAL NUMBER
print_r (array(1, 2, 3, 4, 1.2, 4.6, 7.8, 10));
echo "<br><br>";

# MULTIDIMENSIONAL ARRAY
$animales = array (
"Marinos" => array (
1 => "Delfin", 2 => "Ballena", 3 => "Tiburon"
),
"Terrestres" => array (
1 => "Leon", 2 => "Mono", 3 => "Perro"
),
);
print_r ($animales);
echo "<br><br>";

# FUNCTION ARRAY LENGTH
$myArr = array(0, 1, 2, 3);
function contador($e) {
return "La longitud(length) del array es: ".count($e)."<br><br>";
}
echo contador($myArr);
#count

# FUNCTION WITH 2 ARRAYS
$mySecondArr = array(10, 11, 12);
function unirArr($arr1, $arr2) {
$result = array_merge($arr1, $arr2);
print_r ($result);
}
echo unirArr($myArr, $mySecondArr)."<br><br>";
#array_merge

# FUNCTION ARRAY LAST ELEMENT
function lastEle($e) {
return "El ultimo valor del array es: ".end($e);
}
print_r($myArr);
echo lastEle($myArr)."<br><br>";
#end

# FUNCTION ADD NEW ELEMENT TO THE ARRAY
function addEle($e, $a) {
array_push($e, $a);
print_r ($e);
}
echo addEle($myArr, 200);

#array_push

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

# WEEK CONDITION
$findDay = date('w');
if ($findDay == 1) echo 'We are on Monday';

# MONTH CONDITION
$findMonth = date('m');
if ($findMonth == 10) echo 'We are in October';

# DOUBLE CONDITION
$forMinutes = date('i');
if ($forMinutes <= 10) {
echo "the current minute is less than 10, ";
} else if ($forMinutes >= 15) {
echo "the current minute is more than 15, ";
} else {
echo "does not meet any conditions, ";
}
echo "the current minutes are ".$forMinutes."<br><br>";

# SWITCH
switch ($findDay) {
case 0:
echo 'Hoy es domingo';
break;

case 1:
echo 'Hoy es lunes';
break;

case 2:
echo 'Hoy es martes';
break;

case 3:
echo 'Hoy es miercoles';
break;

case 4:
echo 'Hoy es jueves';
break;

case 5:
echo 'Hoy es viernes y el cuerpo lo sabe';
break;

case 6:
echo 'Hoy es sabado';
break;
}

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

#Date Time
$tiempo = date('Y-m-d');
echo $tiempo."<br><br>";

# Current Date
$tiempoHoy = date('d-m-Y');
echo "La fecha de hoy es: ".$tiempoHoy."<br><br>";

# Current Day

$dia = date("w");
if($dia == 0) echo "Hoy es: Domingo..";
if($dia == 1) echo "Hoy es: Lunes...";
if($dia == 2) echo "Hoy es: Martes..";
if($dia == 3) echo "Hoy es: Miercoles.";
if($dia == 4) echo "Hoy es: Jueves?";
if($dia == 5) echo "Hoy es: Viernes!!!";
if($dia == 6) echo "Hoy es: Sabado.";

echo "<br><br>";

# Current Month (1-12)

$mes = date('n');
echo "Es el mes numero: ".$mes."<br><br>";

# Current Minute (00 - 59)

$minutos = date('i');
echo "Son los minutos actuales: ".$minutos."<br><br>";

?>
32 changes: 32 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
# FUNCTION SUM
function sumar($a, $b) {
$num = 10;
return "($a + $num) =".($a + $num)."<br>($b + $num) =".($b + $num)."<br>";
}
echo sumar(5, 6)."<br><br>";


# FUNCTION MULTIPLY
function multiplicar($a, $b) {
$cien = 100;
return "($a * $cien) =".($a * $cien)."<br>($b * $cien) =".($b * $cien)."<br>";
}
echo multiplicar(2, 10)."<br><br>";


# FUNCTION DIVIDE
function dividir($a, $b) {
$mitad = 2;
return "($a / $mitad) =".($a / $mitad)."<br>($b / $mitad) =".($b / $mitad)."<br>";
}
echo dividir(10, 150)."<br><br>";


# FUNCTION ADD/MULTIPLY/DIVIDE AND "RETURN"
function operaciones($a, $b, $c) {
return ($a + $b / $c);
}
echo operaciones(10, 20, 2)."<br><br>";

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

for ($i = 0; $i < 5; $i++) {
echo "El número en el bucle es: $i<br>";
}

echo "<br>";

#FOREACH

$myArray = array (1, 2, 3, 4, 5);

foreach ($myArray as $value) {
$value = $value * 5;
echo $value."<br>";
}

echo "<br>";

#WHILE

$num = 0;

while($num<=10) {
echo $num." ";
$num++;
}

echo "<br>";

#DO WHILE

$numero = 10;
do {
echo $numero." ";
$numero--;
}
while ($numero >= 0);

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

# ABSOLUTE VALUE
echo abs(-4.5);
echo "<br><br>";

# ROUNDED VALUE
var_dump(round(3.4));
var_dump(round(3.6));
echo "<br><br>";

# HIGHEST VALUE min
echo max(array(1, 2, 3, 6, 4, 5));
echo "<br><br>";

# LOWEST VALUE max
echo min(1, 2, 3, 0, 4, 5);
echo "<br><br>";

# RANDOM NUMBER
echo rand(0, 100);

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

#Aritmetic Operators

echo "<br>";
echo "Aritmetic Operators";
echo "<br>";
echo "<br>";

var_dump(2+2);
echo "<br>";

var_dump(2-2);
echo "<br>";

var_dump(2*2);
echo "<br>";

var_dump(2/2);
echo "<br>";

var_dump(2%2);
echo "<br>";
echo "<br>";

#Comparison Operators

echo "Comparison Operators";
echo "<br>";
echo "<br>";

var_dump(10 == 10);
echo "<br>";

var_dump(10 != 10);
echo "<br>";

var_dump(10 < 15);
echo "<br>";

var_dump(10 > 15);
echo "<br>";

var_dump(10 <= 15);
echo "<br>";

var_dump(10 >= 15);
echo "<br>";
echo "<br>";
#Logical Operators

echo "Logical Operators";
echo "<br>";
echo "<br>";

var_dump(10 == 10 && 5 != 5);
echo "<br>";

var_dump(10 == 10 || 5 != 5);
echo "<br>";

var_dump(!10 == 10);
echo "<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();
?>
6 changes: 6 additions & 0 deletions print.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
echo "Hola Mundo!<br>";
print "Adios Mundo!<br>";
$array = array('name' => 'Juan Francisco', 'lastName' => 'Solano Perez', 'age' => 36, 'newArray' => array(1, 2, 3, 'Hola', 'Adios'));
print_r ($array);
?>
Loading