我需要以下代码的 PHP 循环:生成以下示例的最简单方法是什么。
$a = new ShipPackage('UPS');
$a->setParameter('length','5');
$a->setParameter('width','5');
$a->setParameter('height','5');
$a->setParameter('weight','5');
$combined->addPackageToShipment($a);
如果循环 3X,它应该如下所示:
$a = new ShipPackage('UPS');
$a->setParameter('length','5');
$a->setParameter('width','5');
$a->setParameter('height','5');
$a->setParameter('weight','5');
$combined->addPackageToShipment($a);
$a2 = new ShipPackage('UPS');
$a2->setParameter('length','5');
$a2->setParameter('width','5');
$a2->setParameter('height','5');
$a2->setParameter('weight','5');
$combined->addPackageToShipment($a2);
$a3 = new ShipPackage('UPS');
$a3->setParameter('length','5');
$a3->setParameter('width','5');
$a3->setParameter('height','5');
$a3->setParameter('weight','5');
$combined->addPackageToShipment($a3);