3v4l.org

run code in 300+ PHP versions simultaneously
<?php $output = 'tag: 7.x-2.x-1511112-53-combined tag: 7.x-2.x-1511112-50-static-cache-per-git-dir HEAD, tag: xxxx, origin/HEAD, origin/7.x-2.x, 7.x-2.x tag: 7.x-3.0--alpha5 tag: 7.x-2.2 tag: 7.x-2.1 tag: 7.x-2.0'; $lines = explode("\n", $output); $tag = NULL; foreach ($lines as $line) { $parts = explode(', ', $line); foreach ($parts as $part) { if (preg_match('/^tag: (\d+\.x\-\d+\.\d+(?:|\-\w+\d+))$/', $part, $m)) { $tag = $m[1]; break 2; } } } var_export($tag);

preferences:
25.38 ms | 406 KiB | 5 Q