3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getColors($item_colors, $result = []){ preg_match_all('/(\w+),|(\w+)\/(\w+)/', $item_colors, $colors); foreach ($colors as $key => $value) { if ($key === 0) continue; array_push($result, ...$value); } return array_filter($result); } $item_colors = "Vario Base Unit with steel, large, black/orange"; echo implode(' ', getColors($item_colors)); //steel large black orange var_dump(getColors($item_colors)); // array(4) { // [0]=> // string(5) "steel" // [1]=> // string(5) "large" // [5]=> // string(5) "black" // [8]=> // string(6) "orange" // }
Output for git.master, git.master_jit, rfc.property-hooks
steel large black orangearray(4) { [0]=> string(5) "steel" [1]=> string(5) "large" [5]=> string(5) "black" [8]=> string(6) "orange" }

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:
58.06 ms | 401 KiB | 8 Q