3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ "3000mAh battery", "charges 1 smartphone", "input: 5W (5V, 1A) micro USB port", "output: Micro USB cable: 7.5W (5V, 1.5A)", "recharge time 3-4 hours", "includes Micro USB cable", // "1-Year Limited Warranty", "Lifetime test Warranty test2" ]; $result = []; foreach ($items as $item) { $res = explode(':', $item); if (count($res) > 1) { $key = $res[0]; array_shift($res); $result[$key] = implode(':', $res); continue; } if (is_numeric($item[0])) { $parts = (explode(' ', $item)); $key = array_pop($parts); $result[$key] = implode(' ', $parts); continue; } if (ctype_alpha($item[0])) { $parts = explode(' ', $item); $warranty = array_filter($parts, function ($x) { return strtolower($x) === 'warranty'; }); if (count($warranty) > 0) { $wkey = key($warranty); unset($parts[$wkey]); $result[reset($warranty)] = implode(' ', $parts); continue; } $key = array_shift($parts); $result[$key] = implode(' ', $parts); } } print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [battery] => 3000mAh [charges] => 1 smartphone [input] => 5W (5V, 1A) micro USB port [output] => Micro USB cable: 7.5W (5V, 1.5A) [recharge] => time 3-4 hours [includes] => Micro USB cable [Warranty] => Lifetime test test2 )

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:
179.68 ms | 406 KiB | 5 Q