This is my code:
function menu_MORE (Array $ITEMS){
foreach ($ITEMS as $ITEM) {
echo "<li><i class='$ITEM[icon]'></i>$ITEM[link]</li>";
}
$ITEMS = array('link' => array('Edit','Remove'),
'icon' => array('fa fa-pencil','fa fa-trash'), );
menu_MORE($ITEMS);
I want the output to be:
<li><i class="fa fa-pencil"></i>Edit</li>
<li><i class="fa fa-trash"></i>Remove</li>
I think i need a second rule/parameter but I can’t figured it out how.
Thank you in advance!
>Solution :
Your array is er… "inverted" — you’re doing this, where each key has multiple values:
$ITEMS = array(
'link' => array('Edit','Remove'),
'icon' => array('fa fa-pencil','fa fa-trash')
);
You want to do this, where you have multiple entries of items, each with a single value:
$ITEMS = array(
array(
'link' => 'Edit',
'icon' => 'fa fa-pencil',
),
array(
'link' => 'Remove',
'icon' => 'fa fa-trash',
),
);