PHP Associative Arrays
PHP Associative Arrays Associative arrays are arrays that use named keys that you assign to them. Example $car = array(“brand”=>”Ford”, “model”=>”Mustang”, “year”=>1964); var_dump($car);
PHP Associative Arrays Associative arrays are arrays that use named keys that you assign to them. Example $car = array(“brand”=>”Ford”, “model”=>”Mustang”, “year”=>1964); var_dump($car);
PHP Indexed Arrays In indexed arrays each item has an index number. By default, the first item has index 0, the second item has item 1, etc. Example Create and display an indexed array: $cars = array(“Volvo”, “BMW”, “Toyota”); var_dump($cars);
An array stores multiple values in one single variable: Example $cars = array(“Volvo”, “BMW”, “Toyota”); What is an Array? An array is a special variable that can hold many values under a single name, and you can access the values…
The real power of PHP comes from its functions. PHP has more than 1000 built-in functions, and in addition you can create your own custom functions. PHP Built-in Functions PHP has over 1000 built-in functions that can be called directly,…
The continue statement can be used to jump out of the current iteration of a loop, and continue with the next. Continue in For Loops The continue statement stops the current iteration in the for loop and continue with the…
The break statement can be used to jump out of different kind of loops. Break in For loop The break statement can be used to jump out of a for loop. Example Jump out of the loop when $x is…
The foreach loop – Loops through a block of code for each element in an array or each property in an object. The foreach Loop on Arrays The most common use of the foreach loop, is to loop through the…
The for loop – Loops through a block of code a specified number of times. The PHP for Loop The for loop is used when you know how many times the script should run. Syntax for (expression1, expression2, expression3) {…
The do…while loop – Loops through a block of code once, and then repeats the loop as long as the specified condition is true. The PHP do…while Loop The do…while loop will always execute the block of code at least…