$headers=array(
$requestMethod." /rest/obj HTTP/1.1",
"listable-meta: ".$listablemeta,
"meta: ".$nonlistmeta,
'accept: */*',
);
In the above example, I would like to omit the entire line if $ listablemeta or $ nonlistmeta is empty. Suppose $ listablemeta is empty. Then the array will be:
$headers=array(
$requestMethod." /rest/obj HTTP/1.1",
"meta: ".$nonlistmeta,
'accept: */*',
);
Now I can configure conditional isempty () and set the array accordingly, but what if I want to build an array with about 20 different values, each of which sets only if the variable on each line is not empty, is there another way to set the conditional -within is an array declaration? If not, how can this problem be approached?
Thank!
source
share