note 130151 added to function.array-key-exists

From: Date: Tue, 18 Mar 2025 05:44:28 +0000
Subject: note 130151 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-221983@lists.php.net to get a copy of this message
<?php // Define an associative array $userProfile = [ 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'age' => 30, 'country' => 'USA' ]; // Key to check $keyToCheck = 'email'; // Use array_key_exists to check if the key exists in the array if (array_key_exists($keyToCheck, $userProfile)) { echo "The key '$keyToCheck' exists in the array with value: " . $userProfile[$keyToCheck]; } else { echo "The key '$keyToCheck' does not exist in the array."; } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 182.184.18.191) ---- Manual Page -- https://php.net/manual/en/function.array-key-exists.php Edit -- https://main.php.net/note/edit/130151 Del: integrated -- https://main.php.net/note/delete/130151/integrated Del: useless -- https://main.php.net/note/delete/130151/useless Del: bad code -- https://main.php.net/note/delete/130151/bad+code Del: spam -- https://main.php.net/note/delete/130151/spam Del: non-english -- https://main.php.net/note/delete/130151/non-english Del: in docs -- https://main.php.net/note/delete/130151/in+docs Del: other reasons-- https://main.php.net/note/delete/130151 Reject -- https://main.php.net/note/reject/130151 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221983) next »