- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$str = '$str1var ="str1"; $str2var = "str2"';
$pattern = '/\$(?P<variable>(.*?)*)(?:|\s)=(\s|)"(?P<value>(.*?))"/';
preg_match_all($pattern, $str, $output_array);
var_dump($output_array);