mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-14 10:45:06 +02:00
Added unset function to arrays and variables.
Added the unset function to show the varying effects of deleting/removing variables and elements of an array.
This commit is contained in:
@@ -59,6 +59,9 @@ $float = 1.234;
|
|||||||
$float = 1.2e3;
|
$float = 1.2e3;
|
||||||
$float = 7E-10;
|
$float = 7E-10;
|
||||||
|
|
||||||
|
// Delete variable
|
||||||
|
unset($int1)
|
||||||
|
|
||||||
// Arithmetic
|
// Arithmetic
|
||||||
$sum = 1 + 1; // 2
|
$sum = 1 + 1; // 2
|
||||||
$difference = 2 - 1; // 1
|
$difference = 2 - 1; // 1
|
||||||
@@ -136,6 +139,11 @@ echo $associative['One']; // prints 1
|
|||||||
$array = ['One', 'Two', 'Three'];
|
$array = ['One', 'Two', 'Three'];
|
||||||
echo $array[0]; // => "One"
|
echo $array[0]; // => "One"
|
||||||
|
|
||||||
|
// Add an element to the end of an array
|
||||||
|
$array[] = 'Four';
|
||||||
|
|
||||||
|
// Remove element from array
|
||||||
|
unset($array[3]);
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* Output
|
* Output
|
||||||
|
Reference in New Issue
Block a user