Category

PHP

Advanced Variables and Using Them by Reference in PHP

PHP

Variables by Reference Variables can also hold their value as a reference to another value. This means, a variable simply points to another variable. So whatever value the other variable holds, the reference variable also holds the same. For reference assignment we use an ampersand sign (&) after the equals to sign (=) while assigning a variable. Example: <?php $var1…

Using List in PHP to Access Array Values to Multi Dimensions

PHP

If you are looking to assign the values of an array to a group of variables with one statement, use list(). This construct is used to give a list of variables some value. They work only with arrays that use numeric indexes. Example: <?php $names = array (“Ashish”, “Michael”, “Chris”); list($name1, $name2, $name3) = $names; echo $name1; echo “<br />”;…