I want avoid several ifs and my question is:
Is there a function or a way to add several arrays ($a, $b) to an array, but only if an array ($a, $b) is not empty?
Given:
$a = ['foo' => 'bar'];
$b = [];
My code:
$c = [];
if (count($a))
{
$c['a'] = $a;
}
if (count($b))
{
$c['b'] = $b;
}
Yes, I need string keys with a specific name.