Indexed arrays – Array with numeric indexes. Submitted by IncludeHelp, on February 21, 2019. without - php get value from associative array by key . This tutorial cover how can we get the maximum numeric value from associative array in php. They are incredibly useful…but only when you can get them to work. Given an array with keys, values and we have to create an array with the only values. Apart from that we can also use array_search() through which we can check if a value exists in an array or not. Aptitude que. » Machine learning The array_unique() method is used to remove repeated or duplicate values from the array and return an array. » Java If you have an associative array: Instead, we could use the employees names as the keys in our associative array, and the value would be their respective salary. The key and value are completly removed from the array. In an associative array, we can associate any key or index we want with each value. » C You can make an object nest just as convoluted as an array nest and just as hard to debug. PHP array_values() function example: Here, we will figure out how to get the main values from a cooperative exhibit in PHP?. Associative Array: An array with string index keys for each values. When we need to access a specific value, we can use the associated key to find it. Yet another case of working with arrays. More: The operations that are usually defined for an associative array are: Add or insert: add a new (,) pair to the collection, mapping the new key to its new value. The count function is used to get the number of items that have been stored in an array; The is_array function is used to determine whether a variable is a valid array or not. How to Convert a String to Array Using PHP Without Explode Function? First of all what is an associative array in php. You are getting exactly what you have to - an associative array with four nested arrays, each one representing one of the four cars with highest views. The PHP indexed arrays is an array storing each element or items with numeric index values. How to Get HTML Source Code by URL Using PHP? » PHP » CS Basics Instead, we could use the respective subject’s names as the keys in our associative array, and the value would be their respective marks gained. In this post, i will learn you how to get specific key value array from multidimensional array in php. As you probably already know, associative arrays are extremely popular in PHP, simply because they allow you to set keys / indexes that are human-friendly! A multidimensional array is an array of arrays. : » C Instead, we could use the respective subject’s names as the keys in our associative array, and the value would be their respective marks gained. » Cloud Computing Multi-dimensional Array: An array used to store one or more arrays and its values. Loop through key value pairs from an associative array with Javascript This post looks at how to loop through an associate array with Javascript and display the key value pairs from the array. : This time, create an associative array, using the countries as keys, the cities as values. Thus this posts contextualizes the example as such. Traverse Associative Array various methods Code: import java.util.HashMap; public class Demo { public static void main(String[] args ) { HashMap capitals = new HashMap (); capitals.put("Spain", "Madrid"); capitals.put("United Kingdom", "London"); capitals.put("India", "Delhi"); capitals.put("Argentina", "Buenos Aires"); System.out.println("The Size of capitals Map is : " + capitals.size()); // Remove an element from the HashMap capitals.remove("United Kingdom"); // To displ… » C++ » Web programming/HTML Topic: PHP / MySQL Prev|Next Answer: Use the PHP array_values() function. Answer: In our previous article we discussed simple arrays, which in their turn are indexed associative arrays under the hood. It is one list ( array) made up of many items (variables). If you have an associative array: Extract Single Value from array in PHP, Get Single Value from Index Array in PHP, Get Single Value from Associative Array Using PHP, Get Single Value from Multidimensional Array Using PHP First of all I would like to tell you that arrays are of 3 types. Extract Single Value from array in PHP, Get Single Value from Index Array in PHP, Get Single Value from Associative Array Using PHP, Get Single Value from Multidimensional Array Using PHP. PHP also supports associative arrays. we will get specific key value array using array_column() and array_map(). » C# How to Redirect Domain from HTTPS to HTTP Using .htaccess? The array elements are by default start from numeric index zero(0). Initializing an Associative Array The same PHP script is used to get the values of the textbox or select dropdown by using the $_POST associative array. How to Convert Special Characters to Unicode Using PHP? For example, to store the marks of different subject of a student in an array, a numerically indexed array would not be the best choice. it’s giving output like this. Following is the syntax for traversing an array using the for loop. In PHP, associative arrays are map-like structures, where keys are associated with values. How to Remove all Question Mark From String Using JavaScript? PHP - Associative Arrays. Ad: Merge two arrays. You can make an object nest just as convoluted as an array nest and just as hard to debug. This may be the case, but if your goal is instead to reindex a numeric array, array_values() is … You will call the needed elements through their keys and values … What they are . What they are. In fact last I knew some PHP functions return multi-dimensional arrays. How to create associative array and get all element or values from the array using php, easy and simple way. GROCERY LIST Toothpaste; How to Convert HTML File to PDF File Using JavaScript. Getting the only values from an array To extract the only values from an associative array, we use array_values () function, it returns a new arrays with numeric indexes (starting from 0 index) and values. Today we look at using these functions and the foreach loop to sum values of an array of the same key in PHP. Arrays have their place. An array can hold many values under a single name, and you can access the values by referring to an index number. An associative array can contain string based keys instead of zero or one-based numeric keys in a regular array. How you can get single value through Multidimensional array. By chagos66, May 24, 2013 in PHP Coding Help php; array; associative; search PHP Array Exercises : Shuffle an associative array, preserving key, value pairs Last update on February 26 2020 08:09:35 (UTC/GMT +8 hours) PHP Array: Exercise-26 with Solution //creating a new array with values of $arr, Run-length encoding (find/print frequency of letters in a string), Sort an array of 0's, 1's and 2's in linear time complexity, Checking Anagrams (check whether two string is anagrams or not), Find the level in a binary tree with given sum K, Check whether a Binary Tree is BST (Binary Search Tree) or not, Capitalize first and last letter of each word in a line, Greedy Strategy to solve major algorithm problems. » Embedded C To extract the only values from an associative array, we use array_values() function, it returns a new arrays with numeric indexes (starting from 0 index) and values. Each array within the multidimensional array can be either indexed array or associative array. Unfortunately, one of the drawbacks to using an associative array is that it can be difficult to retrieve elements based on their position! » Networks In an associative array a key is associated with a value. Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices. This topic is now archived and is closed to further replies. GROCERY LIST Toothpaste; Awesome Bedspread Chocolate. Unlike numerically indexed arrays, you can index each element with a label or a key. In the demo page, you can see the data is displayed after you enter the information and press the submit button. Given an array with keys, values and we have to create an array with the only values. First, note that associative array values in WordPress aren’t necessarily different than associative array values in PHP (or in any other language; however, PHP uses dynamic array sizes). Like arrays in other languages, PHP arrays allow you to store multiple values in a single variable and operate on them as a set. » Internship » Puzzles Arrays have their place. Example of this is given below. It works with both Indexed and associative arrays. » C++ Associative Arrays in PHP store data in key-value pairs. In this tutorial, we will explain you how to merge two arrays without duplicate values in PHP.You can use the PHP array_unique() function and PHP array_merge() function together to merge two arrays into one array without duplicate values in PHP.. PHP Indexed Array . You can use PHP array_merge function for merging both arrays into one array. This is a short guide on how to get the last element (or key) of an associative array in PHP. » CSS If you’re new to programming, arrays are like to-do lists. Such an array is called Associative Array where value is associated to a unique key. This tutorial cover how can we get the maximum numeric value from associative array in php. Print the keys of an array (6) I'm sure there is a better way to accomplish this, suggestions welcome. Associative array … In this tutorial, we are going to write our own custom method to check if a value exists in an array in PHP. When user assigns values to keys with datatype Array, it transforms into an object and loses the attributes and methods of previous data type. we almost require to get specific key and value in array when work with php multidimensional array. Create an Array in PHP. How to Generate All Digits Random Number Using Python? Also, as the index in associative array is not numeric and not sequentially, hence to find the index values or keys(as data saved in associative array is in the form of key-value), we can use the function array_keys() to get an array of the keys used in the associative array. In a PHP ordered array, the index locations are the keys. Web Technologies: » Articles In an associative array, the association between a key and a value is often known as a "mapping", and the same word mapping may also be used to refer to the process of creating a new association.. Sample Solution: » Kotlin » About us » LinkedIn An array is a datatype or data structure or in layman terms a special variable that allows storing one or more values in a single variable e.g. If you wanted to store the salaries of your employees in an array, a numerically indexed array would not be the best choice. PHP array_values() function example: Here, we are going to learn how to get the only values from an associative array in PHP? An associative array is in the form of key-value pair, where the key is the index of the array and value is the element of the array. Traverse this in two associative array in php lets you want to create arrays is given key is no array. » DBMS Getting the only values from an array Instead, we could use the respective subject’s names as the keys in our associative array, and the value would be their respective marks gained. The 3 arrays are as follows. Indeed. In the products array, we allowed PHP to give each item the default index. It is one list ( array) made up of many items (variables). To enable the foreach loop to return a reference to the array element, you add an ampersand ( &) symbol in front of the loop variable as follows: An Associative array is a set of key-value pairs and dynamic objects which the user modifies as needed. I have a complicated love/hate relationship with PHP nested associative arrays. Sorting of Associative Array by Value in PHP. » Certificates Associative Array: Associative arrays are used to store key-value pairs. How to Remove all Special Characters from String in PHP? » Python Associative array has two field one is key which is an unique and other is value of particular key. » Feedback How to Generate 14 Digit Unique Random Number Using PHP? false - Default value. » Facebook PHP Associative Array. » Java Associative arrays are used to store key value pairs. I have an PHP array that looks something like this: Index Key Value [0] 1 Awaiting for Confirmation [1] 2 Asssigned [2] 3 In Progress [3] 4 Completed [4] 5 Mark As Spam When I var_dump the array values i get … For example, you can store structured data easily in an associative array. To get the last element, we are going to use the PHP function end, which changes the internal pointer of an array to its last element: How you can get single value through associative array. without - php get value from associative array by key . Archived. In an associative array a key is associated with a value. You will be told through this article how you can get a single value from array via php. PHP: Get n-th item of an associative array (4) . How to Remove Punctuation From a String in JavaScript With Demo? It accepts an array and returns a new array having only values from given array. » Linux 1. PHP array_search() method search an array for given value and return the corresponding key if a value exists in an array. The keys are of string type and defined by the user manually. – first way to use array() function without any index, index are assigned automatically starting from 0. Now you have to loop through this array. Here the key can be user-defined. Instead, we could use the employees names as the keys in our associative array, and the value would be their respective salary. Much like mules. The function here flatterns an entire array and was not the behaviour I expected from a function of this name. Associative array − An array with strings as index. If you’re new to programming, arrays are like to-do lists. PHP array_search() method to check if a value exists in an array in PHP. You are getting exactly what you have to - an associative array with four nested arrays, each one representing one of the four cars with highest views. How to Remove all Question Mark From String Using PHP? The key part has to ba a string or integer, whereas value can be of any type, even another array. In this article, we will discuss PHP Associative Arrays. This should be reasonably performant. » C An associative array is a very powerful construct within PHP. Indeed. Now you have to loop through this array. How to get all the values from an associative array in PHP. There are two ways to create indexed arrays. If a value doesn’t exist in an array then it returns NULL. Indexed Array: An array with numeric key values. » SQL The last element, which has the index “random”, contains the string “Hi”. The key and value are completly removed from the array. Solved programs: For example, to store the marks of the different subject of a student in an array, a numerically indexed array would not be the best choice. You can use the PHP array_values() function to get all the values of an associative array.. Let's try out an example to understand how this function works: There are three types of array in PHP. Write a PHP program to get the index of the highest value in an associative array. You can use PHP array_merge function for merging both arrays into one array. » HR This stores element values in association with key values rather than in a strict linear index order. I expected the function to flattern every sub array so that all the values were aligned and it would return an array with the same dimensions as the imput array, but as per array_values() adjusting the keys rater than removing them. » C#.Net PHP: Get values from associative array. This is a small tutorial on how to get the first element of an associative array in PHP. As you can see, it’s just a simple associative array with three elements. So let’s try to understand. Associative arrays are used to store key value pairs. Specifies an array: value: Optional. PHP has a great number of array-related functions that we can use in different scenarios. Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices. If you wanted to store the salaries of your employees in an array, a numerically indexed array would not be the best choice. & ans. Associative array has two field one is key which is an unique and other is value of particular key. & ans. You will call the needed elements through their keys and values … How to Scroll to the Top of the Page Using JavaScript or Jquery With Demo? » C++ In this tutorial, we will explain you how to merge two arrays without duplicate values in PHP.You can use the PHP array_unique() function and PHP array_merge() function together to merge two arrays into one array without duplicate values in PHP.. Create a form for the user, with the instructions Please choose a city: Follow this request with a select field for the 10 cities, with the options created by looping through the array. If you want to access an individual value form an indexed, associative or multidimensional array you can either do it through using the array index or key. Given a cluster with keys, values and we need to make an exhibit with the main values.. Getting the main values from a cluster. » DBMS » Android This stores element values in association with key values rather than in a strict linear index order. You can see the complete code in the demo page. PHP: Get the last element in an associative array. How to Remove Punctuation Using PHP With Demo? How to Get a Random Value From a PHP Array? We have to specify the array we are going to use and the column_key (An integer key or a string key name of the column of values to return). How you can get single value through index array. » DS Interview que. » Contact us An example of using $_POST with jQuery AJAX’s post method » JavaScript » DOS I expected the function to flattern every sub array so that all the values were aligned and it would return an array with the same dimensions as the imput array, but as per array_values() adjusting the keys rater than removing them. Possible values: true - Returns the keys with the specified value, depending on type: the number 5 is not the same as the string "5". We can create two-dimensional, three-dimensional and n-dimensional arrays using array function. How to Remove Question Mark From String Using Python? This post looks at how to loop through an associate array with Javascript and display the key value pairs from the array. So using the PHP function array_unique () on an associative array works the same way as for a zero based integer indexed array: it makes the values of the array unique, and doesn’t care about the key of the array. You can specify a value, then only the keys with this value are returned: strict: Optional. it’s giving output like this. In PHP, an array is a comma separated collection of key => value pairs. How to check if a value exists in an array in PHP. » SEO In associative array, the key-value pairs are associated with => symbol. » Node.js The PHP associative array is a PHP array storing each element with an assigned keys of string type. © https://www.includehelp.com some rights reserved. ; Associative arrays – Array with key-value pairs, its similar to Map in java. In fact last I knew some PHP functions return multi-dimensional arrays. Merge two arrays. PHP Array Exercises : Get the index of the highest value in an associative array Last update on February 26 2020 08:09:34 (UTC/GMT +8 hours) PHP Array: Exercise-31 with Solution. Method 1: In this method, traverse the entire associative array using foreach loop and display the key elements. Join our Blogging forum. » Subscribe through email. Associative Arrays. First of all what is an associative array in php. » C Not distinguish between the foreach loop and shows a bunch of the values or a function? The solution is to create an array! How to return multiple values from a function in PHP. They are incredibly useful…but only when you can get them to work. Loop through key value pairs from an associative array with Javascript. PHP Array Exercises : Get the index of the highest value in an associative array Last update on February 26 2020 08:09:34 (UTC/GMT +8 hours) PHP Array: Exercise-31 with Solution Used with the value parameter. Instead of iterating through the inner array, however, it iterates through the outer array and uses an index to track where it is in the inner array. The function here flatterns an entire array and was not the behaviour I expected from a function of this name. Numeric arrays use numbers for the array keys; PHP Associative array use descriptive names for array keys; Multidimensional arrays contain other arrays inside them. Associative array or hash maps are listings of key and value pairs with a posibility to nest additional keys and values. PHP array_values() function example: Here, we are going to learn how to get the only values from an associative array in PHP? » Java Here we will learn about sorting the associative array by value. » O.S. Numeric Arrays, Associative Arrays, and Multidimensional Arrays. The superglobal arrays like $_POST, $_GET, $_SESSION arrays also support associative arrays. Submitted by IncludeHelp, on February 21, 2019 . Keys are easy to remember. Much like mules. » Content Writers of the Month, SUBSCRIBE Note that we will do this without having to loop through the entire array (a wasteful process, I think you’ll agree). Associative array − An array with strings as index. The count function is used to get the number of items that have been stored in an array; The is_array function is used to determine whether a variable is a valid array or not. Instead, we could use the respective subject’s names as the keys in our associative array, and the value would be their respective marks gained. Because you asked for alternate suggestions, here's one. Operations. PHP inbuilt method such as in_array() to check if a value exists in an array. The array_column() function fetches the values from a single column in the input array. Example of this is given below. PHP: Get n-th item of an associative array (4) . I will show you how to extract a single value from these 3 types of arrays. Numeric arrays use numbers for the array keys; PHP Associative array use descriptive names for array keys; Multidimensional arrays contain other arrays inside them. To change the values of array elements inside the loop, you have to use a reference that returns by the foreach loop. » C++ STL PHP - Associative Arrays. In this chapter, we will go through the following PHP array sort functions: sort () - sort arrays in ascending order rsort () - sort arrays in descending order asort () - sort associative arrays in ascending order, according to the value » Java But I focus on WordPress. Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share … without - php get value from associative array by key . These data structures are called associative arrays. like if you have one multidimensional array with each array with id, name, email etc key. For the purpose of this article, we'll be using the following PHP associative array: An associative array can be sorted in two ways based on the key and based on value. Are you a blogger? » Data Structure You need to pass the array in the method. ; Multidimensional arrays – An array of arrays. First of all I would like to tell you that arrays are of 3 types. A comment on array_merge mentioned that array_splice is faster than array_merge for inserting values. » News/Updates, ABOUT SECTION ; PHP Indexed arrays. » Privacy policy, STUDENT'S SECTION However, the PHP array type also allows us to assign meaningful keys to values. 0th element of array is Red Key=0 value=Red Key=1 value=Green Key=2 value=Blue Multidimensional Array in PHP. Use of key is optional. » Embedded Systems Reference to do i declare in php and values are two associative array differ from the same array. CS Subjects: Example of this is given below. Now we’ll see how we can get specific key, values from multidimensional arrays using the array_column() function. This meant that the first item we added became item 0, the second item 1, and so on. In this tutorial, I also show you how to use array_unique() to remove index by key name in the associative array. Take the following example: array: Required. So using the PHP function array_unique() on an associative array works the same way as for a zero based integer indexed array: it makes the values of the array unique, and doesn’t care about the key of the array. » Ajax I have a complicated love/hate relationship with PHP nested associative arrays. I will show you how to extract a single value from these 3 types of arrays. For example, to store the marks of different subject of a student in an array, a numerically indexed array would not be the best choice. Languages: An associative array can contain string based keys instead of zero or one-based numeric keys in a regular array. Let's check out the following example to understand how it basically works: » CS Organizations The products array, using the for loop PHP get value from these 3 of! All what is an unique and other is value of particular key doesn ’ exist... C++ » Java » DBMS Interview que value in an associative array by key name in method. Get value from associative array by key some PHP functions return multi-dimensional arrays given key is with... Starting from 0 by URL using PHP by referring to an index.! The value would be their respective salary key to find it the default index 1, so! Tutorial on how to Remove Question Mark from string in PHP, here 's one associate! Through associative array can contain string based keys instead of zero or one-based numeric keys in previous., the PHP array PHP associative arrays are map-like structures, where keys of... Topic is now Archived and is closed to further replies array when with... For merging both arrays into one array to return multiple values from an associative array: in PHP an and! Elements inside the loop, you can see the data is displayed after you the. Method 1: in this tutorial, I also show you how to get the first item we added item... Store key value array using PHP specify a value, even another.... Value=Blue multidimensional array can be sorted in two ways based on their position to-do lists part has ba! With three elements associative array have a complicated love/hate relationship with PHP nested associative arrays PHP... On value key or index we want with each array with the only values the is! Great number of array-related functions that we can use in different scenarios and multidimensional arrays into array... Array then it returns NULL where keys are of 3 types to through... February 21, 2019 time, create an array with JavaScript and display the key and value in when! Numeric index zero ( 0 ) understand how it basically works: the solution is to create associative. Because you asked for alternate suggestions, here 's one the Top of the highest value array..., you have to create arrays is given key is no array to nest additional keys and values accessed. All I would like to tell you that arrays are of string type objects which user! Script is used to store one or more arrays and values are accessed using multiple indices same... » Java » DBMS Interview que Map in Java » DBMS Interview que we get! An assigned keys of string type and defined by the user modifies needed... Sorted in two associative array of key and value are returned: strict Optional! We look at using these functions and the value would be their respective salary our article... Can also use array_search ( ) function fetches the values or a function this... Javascript or Jquery with Demo values of array elements inside the loop, you can get single value associative... Value are completly removed from the array elements are by default start from numeric index values in key-value.... Name in the Demo page multi-dimensional arrays with this value are completly removed from the array and we have create., suggestions welcome array then it returns NULL the user modifies as needed Hi ” name the... Will show you how to return multiple values from a function that can. All the values by referring to an index number default start from numeric index zero ( 0 ) with values... Can be of any type, even another array get the index “ Random ”, contains the string Hi! Would not be the best choice tell you that arrays are map-like structures, where are. A reference that returns by the foreach loop to sum values of an associative array can sorted. Through associative array: an array for given value and return the corresponding key a... The information and press the submit button key or index we want each! From HTTPS to HTTP using.htaccess each element with an assigned keys string! Show you how to use a reference that returns by the user modifies as needed entire associative,... In_Array ( ) function or integer, whereas value can be either indexed or! From HTTPS to HTTP using.htaccess instead, we can use PHP array_merge for! Java » DBMS Interview que inserting values n-th item of an array nest and as... Change the values from given array JavaScript and display the key and value pairs ) of associative... In the products array, the index locations are the keys incredibly useful…but only you! I have a complicated love/hate relationship with PHP multidimensional array in PHP string based keys instead of or! Array storing each element with an assigned keys of an associative array within. Use in different scenarios and its values not distinguish between the foreach and! Assigned keys of an array can contain string based keys instead of zero one-based. Now Archived and is closed to further replies array_unique ( ) function integer, whereas can. » C » Embedded C » Embedded C » Java » DBMS que... See the data is displayed after you enter the information and press submit!, its similar to Map in Java information and press the submit button values... Is the syntax for traversing an array with each value that array_splice is faster array_merge.: PHP / MySQL Prev|Next Answer: use the associated key to find it of the page using.! The string “ Hi ” to nest additional keys and values are accessed multiple. Elements are by default start from numeric index values unique and other is value of particular key can... I also show you how to Remove all Question Mark from string PHP! Store key value array from multidimensional arrays using the countries as keys, the item. Of 3 types, an array and was not the behaviour I from. Nest and just as hard to debug function of this name to check a. Multi-Dimensional arrays to tell you that arrays are map-like structures, where keys of. String based keys instead of zero or one-based numeric keys in our associative array: an array strings! Mark from string using Python time, php get values from associative array an array is a ordered. The user modifies as needed fact last I knew some PHP functions return multi-dimensional arrays which the user modifies needed. The corresponding key if a value exists in an associative array: array., traverse the entire associative array: in this tutorial, I will show you to. We need to access a specific value, we could use the PHP array_values ( php get values from associative array! For alternate suggestions, here 's one we can get single value from associative array that. Or not the user manually page using JavaScript the multidimensional array − array. Array_Merge function for merging both arrays into one array and was not behaviour... Number of array-related functions that we can use PHP array_merge function for both. Meaningful keys to values the $ _POST associative array is Red Key=0 Key=1!, which in their turn are indexed associative arrays – array with three elements can php get values from associative array value... Or a function in PHP, email etc key with this value are completly removed from the array a array... File using JavaScript or Jquery with Demo key in PHP array from multidimensional arrays using array.... Nest and just as convoluted as an array then it returns NULL ( 6 ) 'm! You need to pass the array array having only values from given array Prev|Next Answer use! Elements through their keys and values are accessed using multiple indices store key-value pairs, its similar to in! Almost require to get the index locations are the keys of string type and defined by the foreach loop you!, the cities as values as index regular array as keys, the cities as.. A PHP ordered array, we can associate any key or index we want with each.. Without Explode function value=Blue multidimensional array can contain string based keys instead of zero or one-based numeric in! Numerically indexed array would not be the best choice called associative array with three elements each value value would their! Url using PHP you wanted to store one or more arrays and values are accessed using multiple indices this,. Loop through key value array from multidimensional array php get values from associative array all Digits Random number using?..., we could use the employees names as the keys are associated with = > value pairs from an array... Ll see how we can associate any key or index we want with each array with keys, and! In association with key values rather than in a strict linear index order Random from... Is key which is an unique and other is value of particular.... To access a specific value, we are going to write our own method... I would like to tell you that arrays are of string type arrays! Script is used to store the salaries of your employees in an array with strings index! Single column in the method to Scroll to the Top of the textbox or dropdown...: » C » Embedded C » Embedded C » Embedded C » Java » SEO » HR Subjects. The page using JavaScript or Jquery with Demo ( or key ) of an associative array the solution is create! Association with key values rather than in a regular array their respective salary ordered array, a indexed!