3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 'new message from Bob [22:105:3905:534]', 'user Dylan posted a question in section General', 'new message from Mary(gold) [19504:8728:18524:78941]' ]; $formats = [ '/new message from (\w+) \[(\d+):(\d+):(\d+):(\d+)\]/', // this would actually be something like '/(?<=new message from )(.*)(?=[)(.*)(?=:)(.*)(?=:)(.*)(?=:)(.*)(?=])/' '/user (\w+) posted a question in section ([\w ]+)/', '/new message from (\w+)\((\w+)\) \[(\d+):(\d+):(\d+):(\d+)\]/', ]; foreach ($input as $line) { foreach ($formats as $key => $format) { $data = []; if (preg_match($format, $line, $data)) { array_shift($data); echo 'format: ' . $key . ', data: ' . var_export($data, true) . "\n"; continue; } } }
Output for git.master, git.master_jit, rfc.property-hooks
format: 0, data: array ( 0 => 'Bob', 1 => '22', 2 => '105', 3 => '3905', 4 => '534', ) format: 1, data: array ( 0 => 'Dylan', 1 => 'General', ) format: 2, data: array ( 0 => 'Mary', 1 => 'gold', 2 => '19504', 3 => '8728', 4 => '18524', 5 => '78941', )

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:
47.02 ms | 402 KiB | 8 Q