Created
June 1, 2015 11:45
-
-
Save rafasashi/0d3ebadf08b8c2976a9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_array_value($array=array(), $path=array()){ | |
foreach($path as $key) { | |
if(isset($array[$key])){ | |
$array=$array[$key]; | |
} | |
else{ | |
$array=NULL; | |
break; | |
} | |
} | |
return $array; | |
} | |
function custom_isset($array=array(), $path=array()){ | |
$isset=true; | |
if(is_array($array)&&is_null(get_array_value($array, $path))){ | |
$isset=false; | |
} | |
return $isset; | |
} | |
function is($array=array(), $path=array()){ | |
$is=false; | |
if(is_array($array)){ | |
$array_value=get_array_value($array, $path); | |
if(is_bool($array_value)){ | |
$is=$array_value; | |
} | |
} | |
return $is; | |
} | |
**Example** | |
$status=[]; | |
$status['updated']=true; | |
if(is($status,array('updated'))){ | |
//do something... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment