How to find array dictionary value using key

0 votes

I want to use the key to locate the value in an array.

Like this:

$array=('us'=>'United', 'ca'=>'canada');
$key='ca';

How can I have the value 'canada'?

Aug 1 in PHP by Kithuzzz
• 3,660 points
9 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to delete element by value in array (not key) using php?

Hello @kartik, Using array_search() and unset, try the following: if (($key = ...READ MORE

answered Sep 16, 2020 in PHP by Niroj
• 82,740 points
218 views
0 votes
0 answers

How to sort an array of associative arrays by value of a given key in PHP?

Given this array: $inventory = array( ...READ MORE

Jul 24 in PHP by Kithuzzz
• 3,660 points
19 views
0 votes
0 answers

How to push both value and key into PHP array

Take a look at this code: $GET = ...READ MORE

Jul 25 in PHP by Kithuzzz
• 3,660 points
13 views
0 votes
1 answer

How to search for highest key/index in an array?

Hello @kartik, This should work fine $arr = array( ...READ MORE

answered Oct 6, 2020 in PHP by Niroj
• 82,740 points
112 views
0 votes
1 answer

How to get input field value using PHP?

Hello, Use PHP's $_POST or $_GET superglobals to retrieve the value of ...READ MORE

answered Nov 20, 2020 in PHP by Niroj
• 82,740 points
17,413 views
0 votes
0 answers

How to reverse an array in php WITHOUT using the array reverse method

I have an array called reverse array ...READ MORE

Jun 12 in PHP by narikkadan
• 11,280 points
31 views
0 votes
0 answers

Filter array by its keys using an array of allowed keys

The callback function in array_filter() only passes in the ...READ MORE

Jun 20 in PHP by narikkadan
• 11,280 points
14 views
0 votes
0 answers

Find all second level keys in multi-dimensional array in php

I want to provide a list of ...READ MORE

6 days ago in PHP by Kithuzzz
• 3,660 points
17 views
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,240 points
3,977 views
0 votes
1 answer

How to store input value into array then localstorage?

Hello @ abhittac, You have create the array everytime the ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,740 points
4,897 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP