Array B is dynamically created from your multiple selections.
<select name="selections[]" size="3" multiple>
When you press your submit button, "selections[]" will be passed as an array of your selections, hence why the following code works:
<?
foreach($inventory as $key=>$value)
{
if(!(in_array($key, $selections)))
{
$notSelected[$key] = $value;
}
}
?>
Notice the "in_array" and "$selections"?
What that line is saying is: IF $KEY ISN'T IN THE $SELECTIONS ARRAY, THEN GO AHEAD AND ADD THE $KEY AND $VALUE (OF THE $INVENTORY ARRAY) TO THE NEW ARRAY, CALLED $NOTSELECTED.
I hope this makes it a bit more clear... if not, let me know. :-)
Jason
PS. You can also check to see if they have made ANY selections at all simply by using the following commands:
if(!(is_array($selections)))
{
print("Ops.. you've made no selections.\n");
}
You see, $selections will not become an array unless something is selected.