Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php array filter specific keys

$arr = [
    'foo' => 'bar',
    1 => 'baz',
    'qux' => 22,
    3 => 123,
    'quux' => 'quuz',
];

$filteredArr = array_filter(
    $arr,
    fn ($key) => is_numeric($key),
    ARRAY_FILTER_USE_KEY
);

echo print_r($filteredArr, true); // [1 => 'baz', 3 => 123]
Comment

PREVIOUS NEXT
Code Example
Php :: laravel create controller 
Php :: showing from to in larvel pagination 
Php :: wordpress remove taxonomy from post 
Php :: laravel get route parameters in blade value 
Php :: img upload in php 
Php :: update values in array in php 
Php :: wordpress wp_logout_url redirect 
Php :: php octal to decimal 
Php :: office 2013 
Php :: Remove revisions from Wordpress pages 
Php :: get category of current post wordpress 
Php :: update php version wamp windows 
Php :: create array php 
Php :: return with success message laravel 
Php :: get user auth in laravel 
Php :: .htaccess Prevent access to php.ini 
Php :: php array_push in foreach duplicate 
Php :: Composer detected issues 
Php :: php call constant in class 
Php :: get cookie in laravel 
Php :: worpdress pods taxonomy get custom field 
Php :: if exists in string count php 
Php :: php add new item to associative array 
Php :: laravel with and where 
Php :: laravel ecommerce 
Php :: wordpress rename post format 
Php :: read pdf text php 
Php :: html in php function 
Php :: delay in php 
Php :: laravel collection collapse 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =