I have array
$x = [
name => "tableName",
type => "string",
allowNull => false,
isRequired => true,
isArray => false,
orderNumber => 0
]
and I would like to test if argument in function is like TYPE option in array $x
public function foo(string $fooName, array $params = NULL)
{
// here is some code and ...
foreach ($params AS $key => $val) {
if (// ... now I need to test if $val is like $x['type'] = like string --> is_string($val) or !is_string($val) but how to do that ??) {
// to do something
}
}
}
Is possible to do that?
I try something like
if (${'is_'.$x['type']}()($val)) { }
but this has result "Undefined variable: is_string"