Cheetah
array_key_exists.php
Go to the documentation of this file.
1 <?php
2 
8 // +----------------------------------------------------------------------+
9 // | PHP Version 4 |
10 // +----------------------------------------------------------------------+
11 // | Copyright (c) 1997-2004 The PHP Group |
12 // +----------------------------------------------------------------------+
13 // | This source file is subject to version 3.0 of the PHP license, |
14 // | that is bundled with this package in the file LICENSE, and is |
15 // | available at through the world-wide-web at |
16 // | http://www.php.net/license/3_0.txt. |
17 // | If you did not receive a copy of the PHP license and are unable to |
18 // | obtain it through the world-wide-web, please send a note to |
19 // | license@php.net so we can mail you a copy immediately. |
20 // +----------------------------------------------------------------------+
21 // | Authors: Aidan Lister <aidan@php.net> |
22 // +----------------------------------------------------------------------+
23 //
24 // $Id: array_key_exists.php,v 1.1 2005/07/11 16:34:35 ggiunta Exp $
25 
26 
38 if (!function_exists('array_key_exists')) {
39  function array_key_exists($key, $search)
40  {
41  if (!is_scalar($key)) {
42  user_error('array_key_exists() The first argument should be either a string or an integer',
43  E_USER_WARNING);
44  return false;
45  }
46 
47  if (is_object($search)) {
48  $search = get_object_vars($search);
49  }
50 
51  if (!is_array($search)) {
52  user_error('array_key_exists() The second argument should be either an array or an object',
53  E_USER_WARNING);
54  return false;
55  }
56 
57  return in_array($key, array_keys($search));
58  }
59 }
60 
61 ?>
php