I have a class in which I need to do certain checks on an array, such as checking whether it is associative or indexed. I know there is no native function in PHP that does this, so I could use the example below.
function isAssoc($arr)
{
return array_keys($arr) !== range(0, count($arr) - 1);
}
Example taken from here .
But since I'm working with object-oriented and would like to do things the right way, I know that:
In short, I wanted to implement something like the code below, but in the right way:
public function __construct($name, $content = null, $attributes= null)
{
if(is_assoc($content){
//
}
else{
//
}
}