About time I had a question of my own -- this should be well within my means to solve, but I'm stumped. At any rate, regular expressions have never been my strong suit. I'm also pretty sure this has been answered before, but since the forum's search is so flaky, I couldn't find any previous threads..
Basically, I have a PHP expression stored in a string -- silly example:
$code = '$text = $var1 . " likes cheese more than " . $var2 . ".";';
What the expression in the string does isn't important. What I want is a function that will returns the names of all of the variables in the string as an array. So for the above example, it would return an array with the elements whose values are "$text", "$var1", and "$var2". Remember, a variable in PHP consists of a $ and a letter or underscore, followed by any number of letters, numbers, or underscores. I think the way to go about this is with preg_match_all(), but I've tried everything I can think of.