Skip to main content

Posts

Showing posts from October, 2017

Multidimensional Array Searching - Find key by specific value

Solution is based on the array_search() function. You need to use PHP 5.5.0 or higher. $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'     ) ); Solution-1: function myfunction($products, $field, $value) {    foreach($products as $key ...