note 116635 added to function.array-search

From: Date: Mon, 02 Feb 2015 11:30:04 +0000
Subject: note 116635 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-201576@lists.php.net to get a copy of this message
in (PHP 5 >= 5.5.0) you don't have to write your own function to search through a multi dimensional array ex : $userdb=Array ( (0) => Array ( (uid) => '100', (name) => 'Sandra Shush', (url) => 'urlof100' ), (1) => Array ( (uid) => '5465', (name) => 'Stefanie Mcmohn', (pic_square) => 'urlof100' ), (2) => Array ( (uid) => '40489', (name) => 'Michael', (pic_square) => 'urlof40489' ) ); simply u can use this $key = array_search(40489, array_column($userdb, 'uid')); ---- Server IP: 72.52.91.14 Probable Submitter: 197.44.68.202 ---- Manual Page -- http://php.net/manual/en/function.array-search.php Edit -- https://master.php.net/note/edit/116635 Del: integrated -- https://master.php.net/note/delete/116635/integrated Del: useless -- https://master.php.net/note/delete/116635/useless Del: bad code -- https://master.php.net/note/delete/116635/bad+code Del: spam -- https://master.php.net/note/delete/116635/spam Del: non-english -- https://master.php.net/note/delete/116635/non-english Del: in docs -- https://master.php.net/note/delete/116635/in+docs Del: other reasons-- https://master.php.net/note/delete/116635 Reject -- https://master.php.net/note/reject/116635 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201576) next »