- print_r: documentation ( source)
<?php
class PriceList
{
/**
* @var float[]
*/
protected $data = [];
public function addPrice(float $price): void
{
$this->data[] = $price;
}
/**
* @return float[] Array of prices
*/
public function all(): array
{
return $this->data;
}
}
$priceList = new PriceList();
$priceList->addPrice(29.99);
$priceList->addPrice(89);
$priceList->addPrice(199);
print_r($priceList->all());