note 129809 added to function.array-search

From: Date: Fri, 18 Oct 2024 11:48:23 +0000
Subject: note 129809 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-221598@lists.php.net to get a copy of this message
About searching in multi-dimentional arrays using array_column, to add to the notes from "turabgarip at gmail dot com", here is a workaround to find the correct key: $array_column = 'name'; $searchValue = 'my value ; $result = array_filter($myArray, function ($subarray) use ($array_column, $searchValue) { return isset($subarray[$array_column]) && $subarray[$array_column] === $searchValue; }); echo key($result); ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 194.34.233.10) ---- Manual Page -- https://php.net/manual/en/function.array-search.php Edit -- https://main.php.net/note/edit/129809 Del: integrated -- https://main.php.net/note/delete/129809/integrated Del: useless -- https://main.php.net/note/delete/129809/useless Del: bad code -- https://main.php.net/note/delete/129809/bad+code Del: spam -- https://main.php.net/note/delete/129809/spam Del: non-english -- https://main.php.net/note/delete/129809/non-english Del: in docs -- https://main.php.net/note/delete/129809/in+docs Del: other reasons-- https://main.php.net/note/delete/129809 Reject -- https://main.php.net/note/reject/129809 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221598) next »