Learn PHP Tutorial in Hindi 17 Multidimensional Array and Associative Array
This video is made for learning about Multidimensional Array Associative Array in PHP in Hindi. An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list vector, hash table an implementation of a map, dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible. Two-dimensional Arrays Imagine that you are an owner of a flower shop. One-dimensional array is enough to keep titles and prices. But if you need to keep more than one item of each type you need to use something different - one of the ways to do it is using multidimensional arrays. The table below might represent our two-dimensional array. Each row represents a type of flower and each column – a certain attribute. Explanation of those data structures is beyond the scope of this manual, but at least one example is provided for each of them. For more information, look towards the considerable literature that exists about this broad topic. Syntax Specifying with array fx An array can be created using the array language construct. It takes any number of comma-separated key value pairs as arguments. The comma after the last array element is optional and can be omitted. This is usually done for single-line arrays, is preferred over array. For multi-line arrays on the other hand the trailing comma is commonly used, as it allows easier addition of new elements at the end. The key can either be an integer or a string. The value can be of any type. Additionally the following key casts will occur: Strings containing valid integers will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer. Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8. Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0. Null will be cast to the empty string, i.e. the key null will actually be stored under "". Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type. If multiple elements in the array declaration use the same key, only the last one will be used as all others are overwritten.
Download
0 formatsNo download links available.