Search
 
SCRIPT & CODE EXAMPLE
 

PHP

only fetch specific array keys php

$array = [
    'a' => 4,
    's' => 5,
    'd' => 6,
];
$onlyKeys = ['s','d'];

$filteredArray = array_filter($array, function($v) use ($onlyKeys) {
    return in_array($v, $onlyKeys);
}, ARRAY_FILTER_USE_KEY);

prinr_r($filteredArray); //  ['s' => 5, 'd' => 6]
Comment

PREVIOUS NEXT
Code Example
Php :: why are my css properties not being applied to php file 
Php :: laravel insert multiple rows from form 
Php :: php sum 2 arrays 
Php :: change varchar limit in migration file. 
Php :: apagar windows desde consola 
Php :: php explode and typecast 
Php :: PHP strcasecmp — Binary safe case-insensitive string comparison 
Php :: itop cron.php 
Php :: How to programmatically grab the product description in WooCommerce? 
Php :: query for current editing post id 
Php :: copy(/Users/admin/Library/Caches/composer/files/fakerphp/faker 
Php :: php code for adding dara 
Php :: JsonResource withoutWrapping 
Php :: webmin apache php not working 
Php :: laravel livewire refresh computed property 
Php :: bin/cake cache clear_all 
Php :: PHP OOP - Class Constants 
Php :: assertequals vs assertsame 
Php :: Add custom column at custom posts list 
Php :: generate press viewport 
Php :: php parse_url array function 
Php :: laravel required_if fileld has value 
Php :: simplesaml php logout 
Php :: Do not call the observer when there is a model update in laravel 
Php :: searching for new lines 
Php :: #@923uf8023hFO@I#H# 
Php :: public function __sleep() and __wakeup() 
Php :: symfony 6 download 64 bit 
Php :: php array push key value 
Php :: error php 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =