Here is the array
$anArray = array(
\"theFirstItem\" => \"a first item\",
if(True){
\"conditionalItem\" => \"it may appear base on the condi
Its pretty simple. Create array with essential elements. Then add conditional elements to the array. Now add other elements if required.
$anArray = array(
"theFirstItem" => "a first item"
);
if(True){
$anArray+=array("conditionalItem" => "it may appear base on the condition");
}
$more=array(
"theLastItem" => "the last item"
);
$anArray+=$more;
You modify this code to make it even more shorter,, i have just given elaborated code to make it self explantory. No NULL element, no empty string, put you item anywhere you want, no hassel.