Assume you have a file called data.txt with
car-20,boat-30,
bill-2,john-3,george-4,
$f = file('data.txt') reads the file and creates an array with each element being one line in the file
foreach($f as $key=>$var) cycles through the array setting $var equal to each line in the file. $key in this case will just be the line number starting at zero.
$entry = explode(',',$val) breaks a single line up by commas. So, for the first line, you get two entries car-20 and boat-30.
The entry array is cycled through and exploded by the '-' so you end up with $item=car and $price = 20.
These are then formatted and outputted as a checkbox element.