Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] array_search nie działa
lesz735
post
Post #1





Grupa: Zarejestrowani
Postów: 53
Pomógł: 0
Dołączył: 26.12.2014

Ostrzeżenie: (0%)
-----


Z podręcznika php http://php.net/manual/pl/function.array-search.php wrzuciłem coś takiego:



<?PHP

$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'
)
);
echo '<pre>';
print_r($userdb);
echo '</pre>';

//simply u can use this

$key = array_search(40489, array_column($userdb, 'uid'));
echo '<pre>';
print($key);
echo '</pre>';

echo '<pre>';
print('alamakota');
echo '</pre>';
?>

uruchomiłem i dostaję taki ekran:

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
)

)

Gdzie jest błąd bo nie działa array_search??

Mam
Serwer: Localhost via UNIX socket
Wersja serwera: 5.5.47-0+deb7u1
Wersja protokołu: 10

Dziękuję za pomoc.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 10:54