English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi!

Bellow an example of usage array_key_exists for one dimensional arrat
(MyArr1). How I call array_key_exists for multidimensional (MyArr2) ?

Thanks

$MyArr1=array();
$MyArr1['A']=1;
if (array_key_exists('A', $MyArr1))
print "A exists";
else
print "A doesnt exist";

$MyArr2=array();
$MyArr2['A'][1] = 1;
$MyArr2['A'][2] = 1;

if (array_key_exists(????????????))
print "A1 exists";
else
print "A1 doesnt exist";
?>

2006-09-11 10:34:21 · 4 answers · asked by Vadim 1 in Computers & Internet Programming & Design

4 answers

if (array_key_exists (1, $MyArr2['A']) {
echo "A1 exists";
} else {
echo "A1 does not exist";
}

2006-09-11 11:25:49 · answer #1 · answered by NC 7 · 1 0

"I was wondering, why isn't it *(array[i]) += 500, and cout << *(array[i]) Since they are pointers don't they have to be dereferenced. Why aren't they? " they are. the [] operator dereferences the array array[i] is the same as *(array+i) [ by definition] which also has the strange side effect that array[i] is the same as i[array] Nicholas: array[i] = *(array+i*sizeof(whateverthedatatypeis))... should be: array[i] parses to *(array+i) the compiler takes care of the multiplying by sizeof the array elements -- if you do it again you will get a wrong index into the array

2016-03-26 20:56:19 · answer #2 · answered by Anonymous · 0 0

Array_key_exists

2016-10-06 08:05:41 · answer #3 · answered by mccleery 4 · 0 0

the following page has an example of how to do this for nested arrays.

http://us3.php.net/array_key_exists


(Note: i haven't tried this code myself - i just googled it)

2006-09-11 10:41:51 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers