#associativearray
Explore tagged Tumblr posts
Text
How to use Associative Arrays in PHP

Associative arrays are used to store key value pairs. For example, to store the age of different members of a family in an array, a numerically indexed array would not be the best choice. Instead, we could use the respective member’s names as the keys in our associative array, and the value would be their respective age. There are two ways to create an associative array: Example: $age = array("Anil"=>"45", "Suita"=>"39", "Ravina"=>"23"); or $age = "45"; $age = "39"; $age = "23"; /* Accessing the Associative arrays's elements directly */ echo "Anil is " . $age . " years old.";
Loop Through an Associative Array
To print all the values of an associative array, you can use a foreach loop, like this: Read the full article
1 note
·
View note
Text
Calculate the length of an associative array using JavaScript
Associative arrays are regular arrays in JavaScript where an element is present at a specific index. Associative arrays, on the other hand, are essentially JavaScript objects with user-defined keys in place of the index. Basically, we can say that it stores Key-Value pairs. Syntax: let arr = { key1: 'value'1, key2: 'value2', key3: 'value3'} Key1, Key2, and Key3 are its indexes, and Value1, Value2, and Value3 are its elements. Arr is an associative array in this case. let arr = {"apple": 10, "grapes": 20}; Method 1 The object contains keys method can be used to determine the object's length. Object.keys(counterArray).length; // Output 3 Method 2 We can also count the object's own properties while iterating across the object to determine its length. By doing this, we will disregard the following characteristics of the object's prototype chain: function getLength(object) { var count = 0; for(key in object) { // hasOwnProperty method check own property of object if(object.hasOwnProperty(key)) count++; } return count; } Method 3 The getOwnPropertyNames method is supported by all current browsers (including IE9+), hence the following code can be used to determine the length: Object.getOwnPropertyNames(counterArray).length; // Output 3 Method 4 The method size in the Underscore and Lodash libraries is specifically designed to determine the object length. Although using one of these libraries only for the size technique is not something we advise, if it is currently being done in your project, why not? _.size({one: 1, two: 2, three: 3}); => 3 Read the full article
0 notes
Video
youtube
dict or dictionary how to use in python dict methods use cases of dictionary
इस विडिओ मे पाइथान डिक्ट या डिक्शनेरी के बारे मे बताया गया ���ैं।
की कैसे डिक्ट पाइथान मे उपयोग किया जाता है?
कितने मेथड है डिक्ट के?
#pythonprogramming #Python #Python3 #pythondeveloper #100daysofcodeing #onlineclassroom #onlinelearning #onlineeducation #associativearray #dictionary
इसके साथ कई प्रश्न और प्रोग्राम्स की लिस्ट भी हैं जोकी विडिओ के अंत मे डिस्कस किया
गया है। तो विडिओ अंत तक देखो और इससे जुड़े किसी भी सवाल को कमेन्ट करके पूछो।
0 notes