This is my code with an array of samples. If the user is looking for 523465, then the index should return the main array userdb..Have tried in several ways, but could not get the correct output. Can anybody help me?
<?php
$userdb = Array (
(0) => Array (
(uid) => Array (
(0) => Array (
'10770'
),
(1) => Array (
'523465'
),
(2) => Array (
'4042389'
)
),
(name) => 'Sandra Shush',
(url) => 'urlof100'
),
(1) => Array (
(uid) => Array (
(0) => Array (
'102320'
),
(1) => Array (
'532465'
),
(2) => Array (
'40432389'
)
),
(name) => 'Stefanie Mcmohn',
(pic_square) => 'urlof100'
));
echo '<pre>';
print_r(array_column ( $userdb, 'uid' ));
$key = array_search ( 5432365, array_column ( $userdb, 'uid' ) );
echo ("The key is: " . $key);
source
share