3v4l.org

run code in 300+ PHP versions simultaneously
<?php $selfTable = 'songs'; $relTable = 'artists'; $strings = array( 'id', 'artists.name', '$artist.real_name', '$title' ); foreach($strings as $string) { echo preg_replace_callback('#((?P<both>[^\$]+)|\$(?P<self_field>[\w]+)|\$(?P<table>[\w]+)\.(?P<field>[\w]+))#', function($match) { print_r($match); }, $string); }

preferences:
40.03 ms | 402 KiB | 5 Q