- preg_match_all: documentation ( source)
- array_values: documentation ( source)
- compact: documentation ( source)
- join: documentation ( source)
<?php
$a = 15;
$fl = 3.14;
$boo = true;
$str = "stroka";
$mas = array();
$mas[0] = 'echo "$a $fl $boo $str ";';
preg_match_all('/\$\K[^\s]+/', $mas[0], $matches);
echo join(' ', array_values(compact($matches[0])));