PHP - Array_key_exists
Please tell me how to check the key based on any case.
ow $sec will check for the exact case. How can I make it insensitive Code: [Select] public static function getSMap($sec) { $sects = self::$Mappings; if(array_key_exists($sec, $Mappings)) { return $sects[$sec]; } static $Mappings = array( "BUINESS" => 'business', "TOP 100" => 'business'; "busine" => 'business'; } Similar TutorialsHi, Im encountering this error when i add items to my cart, im using sessions to store my cart items in an array. this error only happens the first time i add something, then if i go clear my session it works and no errors. Code: [Select] Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/byronhea/public_html/oos/mini-cart.php on line 18 Here is the line its refering to Code: [Select] if(array_key_exists($pid, $_SESSION['cart'])) and here is the block of code it belongs to Code: [Select] if(!isset($_SESSION)) { session_start('cart'); } // Process actions $pid = $_POST['prodid']; $q = $_POST['qty']; if(array_key_exists($pid, $_SESSION['cart'])) { $_SESSION['cart'][$pid]=$_SESSION['cart'][$pid]+$q; } ELSE { $_SESSION['cart'][$pid]=$q; } Any help would be appreciated. I'm just wondering if there is a function like array_key_exists that could take an array as the search parameter and check that all keys exist. It would be easy enough to code if I need to but I was hoping it would already exist. All wanted to use it for is a really quick form check to make sure that all the expected values were POSTed before I actually start filtering and validating individual fields. Thanks in advance for any recommendations |