Help me sort $item[]. I have been trying whole day but do not seem to find the right way.
[php]class Item {
private $name = "";
private $itemValues = 0.00;
public $price = 0.00;
public $quantity = 1;
// constructor with default values (used when parameters not passed)
public function __construct($name="unknown",$itemValue= 0.00) {
$this->name = $name;
$this->itemValue = $itemValue;
}
// accessors and mutators
function getName() { return $this -> name; }
function getItemValues() { return $this -> itemvalues; }
function setName($name) { $this -> name = $name; }
function setItemValue($itemValue) { $this -> itemValues = $itemValues;}
function printProperties() {
print ("For name ".$this->name.", the itemValue is ".$this->itemValue."<br/><br/>");
}
}
print(" SlotCar Report");
function printTitle ( ) { // print heading line
print '<th><th> Name </th><th><th> ItemValues </th></tr>
<br/><br/>';
}
function totalItemValues ( &$sumValues ) { // pass array as reference parm
$sum = 0.00;
foreach ($sumValues as $c) {
$sum += $c;
}
return $sum;
}
function printFooting ($totalItemValues) { // print a report footing line
print("<tr><th colspan=2 align=\"right\"><br/> Total of Item Value:</th>
<td align=\"right\"><br/>$totalItemValues</td></tr>");
}
// main
$fn = “slotcar.csv”;
$fp = fopen($fn, “r”);
$delimiter = ‘,’; // field delimiter
$itemValues = array( ); // optional, for documentation
$totalItemValues = 0.00;
print("
fclose($fp);[/php]
?>