3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $item['value'] = "1 teaspoon of fish sauce"; $instruction = strtolower($item['value']); $searchArray = array("grams", "kilograms", "ounces", "tablespoon", "teaspoon"); $swapArray = array("g", "kg", "oz", "tbsp", "tsp"); foreach($searchArray as $search){ if(strpos($instruction, $search)){ $key = array_search($search, $searchArray); echo $key; $instructionTmp = strtr($instruction, array($search => $swapArray[$key])); $instruction = $instructionTmp; } } echo $instruction;
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
41 tsp of fish sauce
Output for hhvm-3.10.0

Process exited with code 153.