3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$s = "--included-- in package price: 5 % vat aed 10.00 destination fee per night 2 % municipality fee 3.5 % packaging fee 10 % warranty service charge breakfast"; $s = "--included-- in product price: breakfast --excluded--: 5 % vat aed 10.00 destination fee per night 2 % municipality fee 3.5 % packaging fee 10 % warranty service charge"; $results = []; if (preg_match_all('~(--(?:(?:not )?in|ex)cluded--)(?:\s+([a-zA-Z ]+))?:+\s*((?:(?!--(?:(?:not )?in|ex)cluded--).)*)~su', $s, $m, PREG_SET_ORDER, 0)) { foreach ($m as $v) { $lastline=array_pop($v); // Remove last item //print_r($details); if (preg_match_all('~(?:(\b(?:usd|aed|mad|usd)\b|\B€|\bus\$)\s*)?\d+(?:\.\d+)?(?:(?!(?1))\D)*~u', $lastline, $details)) { $results[] = array_merge($v, $details[0]); } else { $results[] = $v; } } //[3] => 5 % vat aed [4] => 10.00 destination fee per night //[3] => 5 % vat [4] => aed 10.00 destination fee per night } print_r($results);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [0] => --included-- in product price: breakfast [1] => --included-- [2] => in product price ) [1] => Array ( [0] => --excluded--: 5 % vat aed 10.00 destination fee per night 2 % municipality fee 3.5 % packaging fee 10 % warranty service charge [1] => --excluded-- [2] => [3] => 5 % vat [4] => aed 10.00 destination fee per night [5] => 2 % municipality fee [6] => 3.5 % packaging fee [7] => 10 % warranty service charge ) )

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:
27.06 ms | 407 KiB | 5 Q