473,473 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multidimensional array: see if 1st key is available

Hi,

I've got an multidimensional array
$ret = $country_code[$countryCode][$langCode];

Now I want to see if $countryCode is even in that array, because if it's
not, it doesn't make many sense to look further for $langCode.

Eg.

$country_code = array('BE' =>
array ('en' => 'Belgium',
'nl' => 'België'),
'NL' =>
array ('en' => 'Netherlands',
'nl' => 'Nederland'),
);

Searching for 'BE' would make sense, but 'LP' wouldn't.

I already tried:
$arr = array($country_code['LP']);
if (sizeof($arr) == 0)
print "LP not found!"

But that doesn't seem to work :-s. Would sb have any suggestions?
Greetings,
Mattias

Jul 17 '05 #1
2 1903
"Mattias.Campe" <Ma******************************@UGent.be> wrote:
I've got an multidimensional array
$ret = $country_code[$countryCode][$langCode];

Now I want to see if $countryCode is even in that array, because if it's
not, it doesn't make many sense to look further for $langCode.


array_key_exists()

http://uk.php.net/manual/en/function...key-exists.php

HTH;
JOn
Jul 17 '05 #2
Jon Kraft wrote:
"Mattias.Campe" <Ma******************************@UGent.be> wrote:

I've got an multidimensional array
$ret = $country_code[$countryCode][$langCode];

Now I want to see if $countryCode is even in that array, because if it's
not, it doesn't make many sense to look further for $langCode.

array_key_exists()

http://uk.php.net/manual/en/function...key-exists.php


Perfect! Thx Jon!

Greetings,
Mattias

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
2
by: chris | last post by:
Hi there, I created a Multidimensional array of labels Label lblMultiArray = new Label { {Label3, LblThuTotal}, {Label4,LblFriTotal} }; Now I would like to compare the values in the array,...
10
by: | last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily complicated than the other languages I know. I feel this is because there aren't many good official resources out there to...
3
by: Tyrone Slothrop | last post by:
I have created a script which recurses a display of directories like so: <? $dir = "/path/to/base/directory"; function scan_dir_recurse ($dir,$tab) { global $fileArr; $tab++; if ($tab 4) {...
2
by: BB | last post by:
Hello, I have a HTML form containing multidimensional selects listing equipments and their quantitites. This allow the users to select the kind of equipment and quantitites they would like to...
23
by: drazet | last post by:
hi,all i have a question about multidimensional array. int w,(*pw); pw=w; is *(pw+1) wrong?why? and *(w+2),pw and *(pw+2) mean?
5
by: LittleCake | last post by:
Hi All, I have a multidimensional array where each sub-array contains just two entries, which indicates a relationship between those two entries. for example the first sub-array: =Array ( =30...
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.