3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Prices { private $priceList = array( /* HR EN DE FR IT ES */ /* HR */ '0 100 100 100 100 100', /* EN */ '80 0 120 120 120 120', /* DE */ '80 120 0 120 120 120', /* FR */ '80 120 120 0 120 120', /* IT */ '80 120 120 120 0 120', /* ES */ '80 120 120 120 120 0', ); private $coef = 1; private $languages = array('HR', 'EN', 'DE', 'FR', 'IT', 'ES'); // Must be the same order as in $priceList public function getRate($source, $target) { $this->verifyPriceList(); $sourceKey = array_search($source, $this->priceList); $targetKey = array_search($target, $this->priceList); return intval(explode('\t', $this->priceList[$sourceKey])[$targetKey]); } /* $priceList must not contain spaces */ private function verifyPriceList() { if (strstr(implode('', $this->priceList), ' ') !== FALSE) throw Exception('Price list contains spaces! Location: class.Prices.php'); } } $p = new Prices(); echo $p->getRate('HR', 'EN'); ?>
Output for git.master, git.master_jit, rfc.property-hooks
0

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.18 ms | 401 KiB | 8 Q