find array key in php
function findKey($array, $keySearch)
{
foreach ($array as $key => $item) {
if ($key == $keySearch) {
echo 'yes, it exists';
return true;
} elseif (is_array($item) && findKey($item, $keySearch)) {
return true;
}
}
return false;
}
<?php
$search_array = array('first' => null, 'second' => 4);
// returns false
isset($search_array['first']);
// returns true
array_key_exists('first', $search_array);
?>
Also in PHP:
- check if number is multiple of 3 in php
- eloquent get only some columns
- cancel stripe subscription php
- No match for argument: phpmyadmin yum
- Demonstrate the use of Loops and arrays in PHP
- acf add options page to custom post type
- Interval Between Different Dates
- Laravel catch TokenMismatchException
- ! array_key_exists php
- array_key_exists contains string
- PHP try catch all exceptions
- eloquent relationships
- add a snippet in twig shopware 6
- best way to redirect with php
- debian php switch version
- data() php
- create seeds laravel
- array_intersect php
- error messaging php
- Allowed memory size of 1610612736 bytes exhausted for laravel
- error reporting set 0 in php
- dte fucntion parameters in php
- config:clear cache:clear
- enable error php