Basic Tutorial : PHP Multidimensional Array Function Plus Example. Learn PHP array function is essential in making the program because it adds a level of flexibility of a variable, which is why I call it an extra weapon in the use of a variable (that you have mastered in the previous section, right?). Examples that you can do with PHP is to transpose the array of data into a form that we want, manipulate data from a database, and others.
Basic Tutorial : PHP Multidimensional Arrays Function Plus Example
Simply put, the syntax of PHP arrays are as follows :
$array = array("valiue1","valiue2","value3","value4");
If we apply to web programming, the following is an example :
This command will save all values into a variable ($day), and automatically allocates a number to each element of the array sequentially starting from 0 (please keep in mind, ranging from 0, to avoid confusion when using arrays to manipulate variables). From the example above, use the zero (0) for sunday, one (1) for monday and the next number to the next value.
To take one of the variables in a php array(), way is to use the following syntax:
Replace the zero (0) with the number of variables that you want to appear. Remember, the sequence number starting from 0.
The following is a complete example to show certain variable from a php array() :
<?php $day= array("monday","sunday","tuesday","wednesday","thursday","friday","saturday"); Echo $day; ?>
The result is a Sunday. Please prove …
PHP Multidimensional Array Function
Once we know the basics of php array function, next is to understand php array() is a more complex php multidimensional array function. What is a php multidimensional array function? This function is used to store a variable which has several sub-variables. To better understand the php multidimensional arrays, please refer to the following example :
<?php $fruit= array( "apple" => array("color" => "green", "flavor" => "sweet"), "strawberry" => array("color" => "red", "flavor" => "acid"), ); echo "Characteristics of the apple is has "; echo $fruit["apple"]["color"]; echo " color with a "; echo $fruit["apple"]["flavor"]; echo " flavor"; ?>
Hopefully a bit of discussion on php multidimensional array can useful for you. Don’t forget to practice it so that we become more proficient in mastering the php programming …