Fatal error: Call to undefined function: array_key_exists()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saeen
Forum Newbie
Posts: 24
Joined: Mon Sep 22, 2003 5:35 am
Contact:

Fatal error: Call to undefined function: array_key_exists()

Post by saeen »

hello thr
well im gettin this error "Fatal error: Call to undefined function: array_key_exists() in " in a php file .. the parameters provided are right and nuthin seems to be wrong but i dono y control jus doesnt move on from this function...can any one tell me wat can the reason be?
thank u
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What version of PHP are you using?

Mac
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

im guessing you are using an older version of PHP!?

That will be your problem. The function had a different name in earlier version - key_exists() i think.

Mark
saeen
Forum Newbie
Posts: 24
Joined: Mon Sep 22, 2003 5:35 am
Contact:

Post by saeen »

im using PHP - 4.0.5
ive also tried the key_exists() function but still i face the same error!!!! actually im modifying code written by someone else and the code is so complicated one file contains thousand lines and it is still passing control to other file which itself contains thousand lines so confusingg:S
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

read the manual here for version info regarding this function
http://se.php.net/manual/en/function.ar ... exists.php
saeen
Forum Newbie
Posts: 24
Joined: Mon Sep 22, 2003 5:35 am
Contact:

Post by saeen »

well i tried both functions but nuthin seems to work:S
ERROR:
Fatal error: Call to undefined function: key_exists() in C:\apache\htdocs\kfp\admin\actions\managecompanies.php on line88
code on line 88:
if (!key_exists($companyId, $companyList)) {
if (sizeof($companyList) > 0) {
$keys = array_keys($companyList);
$companyId = $keys[0];
}

companyId is empty when the first time this condition is executed...but ive also tried to assign it a value b4 passin it on but no use still the same error
}
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Basically in the version of PHP you are using neither key_exists() or array_key_exists() are available to you as functions.

I would be trying to upgrade my version of PHP.

Mac
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

possible work around (from the manual)

Code: Select all

function arrayKeyExists($key, $search) { 
   return in_array($key, array_keys($search)); 
}
Mark
Post Reply