I know PHP has a lot of functions for arrays, but I am not sure which one to use know, or if custom function is needed.
I have a function that accepts arrays, and I would need those arrays passed as arguments to have certain keys. When an array is passed, I would need to check if the form of the arrays is proper, example:
<?php function( $array ) {
// Array needs to have form Array('server'=>, 'database'=>,'username'=>
I could check it as "array_key_exists", but it seems too long, there must be a
a way to iterate throught arguments
$template = Array('server'=>'', 'database'=>'','username'=>'');
foreach( $array AS $key => $value ) {
//Somehow compare if array $array includes keys as $template
Is there any way to do this? Thank you very much.
Array_intersect_keymight be useful here.