// Make the array in JS
const array = [0, 1, 2];
array[4] = 4;
console.log(array[3]);
// outputs "undefined"
/* at the third index the array will get the value "undefined" because the value - 4 will be placed at the fourth index and the code will not skip the third index */
// Make the array in PHP
$arr = [0, 1, 2];
$arr[4] = 4;
echo $arr[3];
// unlike JS, that code will not returns anything, there is nothing in 3rd index.
// another interesting fact about it
console.log(array.length); // in JS
echo (count($arr)); // in PHP
// returns 5 in JS and 4 in PHP because in JS the 3rd index got the value - "undefined", but in PHP it just skipped the 3rd index and took the 4th position.<?php
// associative array
$University = [
"name"=>"TSU",
"location"=>"Tbilisi",
"rating"=>"the best",
"faculty"=>"Social & Political Sciences",
"degree"=>"PhD"
];
echo 'Georgia has an ancient university '. $University['name'] . ' which is in ' . $University['location'] .'.' . "\n";
echo 'TSU is ' . $University['rating'] . ' in region' .'.' ."\n";
echo $University['name'] . ' is my university because I study there at the faculty of ' . $University['faculty'] .'.' . "\n";
echo 'my current level of teaching is ' . $University['degree'] .'.' . "\n";
?>
<?php
$hello = "Hi!";
$a = 'hello';
echo $$a;
// output "Hi!"
?>
<?php
// Multidimensional array
$regions = [
"Kakheti"=> [
"city_1"=>"Telavi",
"city_2"=>"Gurjaani",
"city_3"=>"Kvareli",
"City_4"=>"Sighnaghi"
],
"ShidaKartli"=> [
"City_1"=>"Kaspi",
"City_2"=>"Gori",
"City_3"=>"Kareli",
"City_4"=>"Khashuri"
],
"Imereti"=> [
"city_1"=>"Kutaisi",
"city_2"=>"Zestafoni",
"city_3"=>"Terjola",
"City_4"=>"Chiatura"
]
];
echo 'Kakheti is the region of Georgia' . '.' . ' Its largest city is ' . $regions['Kakheti']['city_1'] . "\n";
echo 'My homeland is ' . $regions['ShidaKartli']['City_1'] . '.' . 'I like also ' . $regions['ShidaKartli']['City_2'] . "\n";
echo '2 years ago'. ',' . ' I visited to Imereti Firstly I went to ' . $regions['Imereti']['city_1'] . "\n";
echo 'after I went to '. $regions['Imereti']['city_3'] . ' and ' . $regions['Imereti']['city_2'] . "\n";
?>
$x++; // equivalent to $x = $x+1;
$x--; // equivalent to $x = $x-1;
$x++; // post-increment
$x--; // post-decrement
++$x; // pre-increment
--$x; // pre-decrement
The difference is that the post-increment returns the original value before it changes the variable, while the pre-increment changes the variable first and then returns the value.
Example:
$a = 2; $b = $a++; // $a=3, $b=2
$a = 2; $b = ++$a; // $a=3, $b=3
<?php
# String Functions
// Function strlen() returns the length of the string, example:
echo strlen ("Nice to meet you!") . "\n"; /* output - 17 */
// Function strrev() returns the Reverse of the string, example:
echo strrev ("Nice to meet you!") . "\n"; /* output - !uoy teem ot eciN */
// Function strpos() tries to find the second parameter and returns its index. example:
echo strpos ("Nice to meet you", "you") . "\n"; /* output - 13 */;
// Function str_replace() replaces the word "Hello" with "Hi" , example:
echo ("Hello", "Hi", "Hello there") . "\n"; // outputs - Hi there;
// Function substr() returns the substring between given indexes, example:
echo substr("Nice to meet you", "5") . "\n"; // outputs - to meet you;
echo substr("Nice to meet you", 5, 3) . "\n"; // outputs - to meet you;
// Function trim() removes whitespaces from sides of the string, example:
echo trim(" Nice to meet you ") . "\n"; // outputs - Nice to meet you;
// Function strtoupper() converts the string to upper case, example:
echo strtoupper("Nice to meet you") . "\n"; //outputs - NICE TO MEET YOU;
// Function strtolower() converts the string to lower case, example:
echo strtolower("NICE To Meet You") ; //outputs - nice to meet you;
// Function explode() breaks the string by its delimiter, example:
print_r (explode(" ", "It's the first day of the course!"));
// Function implode() joins the array element based on the delimiter and returns the string, example:
echo implode(" ", ['Nice', 'to', 'meet', 'you']); //outputs - Nice to meet you;
// The PHP str_word_count() function counts the number of words in a string, example:
echo str_word_count("Nice to meet you!"); // outputs - 4
?>
$primaryColor: #ec7705;
a {
color: $primaryColor;
}
After Sass preprocessor:a {
color: #ec7705;
}
.site-header nav {
ul {
padding: 0;
margin: 0;
}
li {
list-style: none;
float: left;
}
}
After Sass preprocessor:.site-header nav ul {
padding: 0;
margin: 0;
}
.site-header nav li {
list-style: none;
float: left;
}
css-minify
package must be installed globally
npm install css-minify -g
Installing globally is necessary.
Before minify command is run, css-dist
directory must be created, where the output will be saved.
The command: css-minify -f css/d1.css
will minify the specified .css file.