Perhaps an object that can store a collection of car objects? You can make use of PHP 5's object iterators, too:
<?php
class Car
{
public $name;
public $size;
public $link;
public function __construct($name, $size='', $link='')
{
$this->name = $name;
$this->size = $size;
$this->link = $link;
}
}
class CarCollection implements Iterator
{
private $collection = array();
/**
* Add Car object to collection
* @return bool
* @param object $car
*/
public function addCar(Car $car)
{
$this->collection[] = $car;
return true;
}
/* methods to implement Iterator: */
public function rewind()
{
reset($this->collection);
}
public function current()
{
return current($this->collection);
}
public function key()
{
return key($this->collection);
}
public function next()
{
return next($this->collection);
}
public function valid()
{
return $this->current() !== false;
}
}
// Example usage:
$carLot = new CarCollection();
// add some test data:
foreach(range(1,9) as $num)
{
$carLot->addCar(new Car("Name $num", "size $num", "link $num"));
}
// use the object iterators to view data:
echo "<ul>\n";
foreach($carLot as $k1 => $car)
{
echo "<li>$k1:\n<ul>\n";
foreach($car as $key => $value)
{
echo "<li>$key: '$value'</li>\n";
}
echo "</ul>\n</li>\n";
}
echo "</ul>";