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, 2022 in PHP by Kithuzzz
• 38,010 points
692 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,880 points
1,602 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, 2022 in PHP by Kithuzzz
• 38,010 points
436 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, 2022 in PHP by Kithuzzz
• 38,010 points
1,355 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,880 points
391 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,880 points
67,410 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, 2022 in PHP by narikkadan
• 63,420 points
1,838 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, 2022 in PHP by narikkadan
• 63,420 points
216 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

Aug 6, 2022 in PHP by Kithuzzz
• 38,010 points
1,241 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
5,270 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,880 points
8,666 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP