3v4l.org

run code in 200+ PHP versions simultaneously
<?php header('Content-Type: application/json'); error_reporting(E_ALL); ini_set('display_errors', 1); class Mushroom { public $microdose = 0.25; public $regular = 2.5; public $heroic = 5.0; public $wetRatio = 9.3; public $wet = null; public $maoRatio = 2; public $mao = null; public $dosageFactor = null; public $strains = [ "azurenscens" => "1.78", "bohemica" => "1.34", "semilanceata" => ".98", "baeocystis" => ".85", "cyanescens" => ".85", "tampanensis" => ".68", "cubensis" => ".63", "weilii" => ".61", "hoogshagenii" => ".60", "stuntzii" => ".36", "cyanofibrillosa" => ".21", "liniformans" => ".16", "penis envy" => "1.35" ]; public function __construct() { ksort($this->strains, SORT_NATURAL | SORT_STRING); $this->wet = $_GET['wet'] ?? 0; $this->mao = $_GET['mao'] ?? 0; if ($this->wet && $this->mao) { $this->microdose = (($this->microdose * $this->wetRatio) / $this->maoRatio); $this->regular = (($this->regular * $this->wetRatio) / $this->maoRatio); $this->heroic = (($this->heroic * $this->wetRatio) / $this->maoRatio); } else if ($this->wet) { $this->microdose = $this->microdose * $this->wetRatio; $this->regular = $this->regular * $this->wetRatio; $this->heroic = $this->heroic * $this->wetRatio; } else if ($this->mao) { $this->microdose = $this->microdose / $this->maoRatio; $this->regular = $this->regular / $this->maoRatio; $this->heroic = $this->heroic / $this->maoRatio; } } public function getAll() { $dose = []; foreach ($this->strains as $strain => $potency) { $this->dosageFactor = $potency / $this->strains['cubensis']; $dose[$strain]['name'] = "Psilocybin " . ucfirst($strain); $dose[$strain]['microdose'] = round(($this->microdose / $this->dosageFactor), 2); $dose[$strain]['regular'] = round(($this->regular / $this->dosageFactor), 2); $dose[$strain]['heroic'] = round(($this->heroic / $this->dosageFactor), 2); } return $dose; } public function getMicrodose() { $dose = []; foreach ($this->strains as $strain => $potency) { $this->dosageFactor = $potency / $this->strains['cubensis']; $dose[$strain]['name'] = "Psilocybin " . ucfirst($strain); $dose[$strain]['microdose'] = round(($this->microdose / $this->dosageFactor), 2); } return $dose; } public function getRegular() { $dose = []; foreach ($this->strains as $strain => $potency) { $this->dosageFactor = $potency / $this->strains['cubensis']; $dose[$strain]['name'] = "Psilocybin " . ucfirst($strain); $dose[$strain]['regular'] = round(($this->microdose / $this->dosageFactor), 2); } return $dose; } public function getHeroic() { $dose = []; foreach ($this->strains as $strain => $potency) { $this->dosageFactor = $potency / $this->strains['cubensis']; $dose[$strain]['name'] = "Psilocybin " . ucfirst($strain); $dose[$strain]['heroic'] = round(($this->microdose / $this->dosageFactor), 2); } return $dose; } } $mushroom = new Mushroom(); echo json_encode($mushroom->getAll());
Output for 7.1.25 - 7.4.0rc1
{"azurenscens":{"name":"Psilocybin Azurenscens","microdose":0.09,"regular":0.88,"heroic":1.77},"baeocystis":{"name":"Psilocybin Baeocystis","microdose":0.19,"regular":1.85,"heroic":3.71},"bohemica":{"name":"Psilocybin Bohemica","microdose":0.12,"regular":1.18,"heroic":2.35},"cubensis":{"name":"Psilocybin Cubensis","microdose":0.25,"regular":2.5,"heroic":5},"cyanescens":{"name":"Psilocybin Cyanescens","microdose":0.19,"regular":1.85,"heroic":3.71},"cyanofibrillosa":{"name":"Psilocybin Cyanofibrillosa","microdose":0.75,"regular":7.5,"heroic":15},"hoogshagenii":{"name":"Psilocybin Hoogshagenii","microdose":0.26,"regular":2.63,"heroic":5.25},"liniformans":{"name":"Psilocybin Liniformans","microdose":0.98,"regular":9.84,"heroic":19.69},"penis envy":{"name":"Psilocybin Penis envy","microdose":0.12,"regular":1.17,"heroic":2.33},"semilanceata":{"name":"Psilocybin Semilanceata","microdose":0.16,"regular":1.61,"heroic":3.21},"stuntzii":{"name":"Psilocybin Stuntzii","microdose":0.44,"regular":4.38,"heroic":8.75},"tampanensis":{"name":"Psilocybin Tampanensis","microdose":0.23,"regular":2.32,"heroic":4.63},"weilii":{"name":"Psilocybin Weilii","microdose":0.26,"regular":2.58,"heroic":5.16}}