- preg_replace_callback: documentation ( source)
- print_r: documentation ( source)
<?php
$selfTable = 'songs';
$relTable = 'artists';
$strings = array(
'id',
'artists.name',
'$artist.real_name',
'$title'
);
foreach($strings as $string) {
echo preg_replace_callback('#\$([\w]+)\.([\w]+)#', function($match) {
print_r($match);
}, $string);
}