array filter use key
$my_array = ['foo' => 1, 'hello' => 'world'];
$allowed = ['foo', 'bar'];
$filtered = array_filter(
$my_array,
function ($key) use ($allowed) {
return in_array($key, $allowed);
},
ARRAY_FILTER_USE_KEY
);?php
$data= [
0 => [1, 'test1'],
1 => [2, 'test2'],
2 => [3, 'test3'],
];
$ids = array_map(function($item) {
return $item[0];
}, $data);
var_dump($ids);
Also in PHP:
- add 1 day to the some date
- date 'F' what is it
- bind in pdo
- add page nos. to existing pdf in php
- all php errors
- day of week by date php
- carbon format date in laravel
- count letters in string php
- SQLSTATE[42000]: Syntax error or access violation: 1071
- codeigniter get last insert
- ethrow exception php
- check value in array key php
- exception php throw
- acheck key exist in array php
- enable ext-dom mod
- check php version linux terminal
- clear config cache laravel 5
- Your Composer dependencies require the following PHP extensions to be installed: fileinfo
- clear the saved cache of my laravel websitefor all the users
- * in array key php
- ci db query error
- check if in array php key
- Allowed memory size of 134217728 bytes exhausted setup di compile
- check php for errors