fork download
  1. <?php
  2. $produk = [
  3. ["nama" => "Motor", "harga" => 18000000],
  4. ["nama" => "Sepeda", "harga" => 500000],
  5. ["nama" => "Headphone", "harga" => 1000000],
  6. ["nama" => "Baju", "harga" => 40000],
  7. ["nama" => "Jam", "harga" => 20000]
  8. ];
  9.  
  10. echo "<ul>";
  11. foreach ($produk as $item) {
  12. echo "<li>{$item['nama']} - Rp " . number_format($item['harga'], 0, ',', '.') . "</li>";
  13. }
  14. echo "</ul>";
  15. ?>
Success #stdin #stdout 0.02s 25748KB
stdin
Standard input is empty
stdout
<ul><li>Motor - Rp 18.000.000</li><li>Sepeda - Rp 500.000</li><li>Headphone - Rp 1.000.000</li><li>Baju - Rp 40.000</li><li>Jam - Rp 20.000</li></ul>