Step 1: Identify Your Quarry
function find_variable($code) {
foreach ($code as $line) {
if (strpos($line, '$var') !== false) {
return $line;
}
}
return null;
}
Step 2: Stalk Your Prey
function stalk_variable($code, $var) {
pattern = '/\$var\.[a-zA-Z0-9_]+/';
if (preg_match($pattern, $code)) {
return true;
}
return false;
}
Step 3: Strike
function strike_variable($code, $var) {
pattern = '/\$var\.[a-zA-Z0-9_]+/';
$code = preg_replace($pattern, '', $code);
return $code;
}
Now, go forth and hunt those variables!
For more advanced techniques, see Chaotic Code Advanced Variable Hunting Techniques
Or, for a more philosophical approach, see Variable Nomads: The Art of Variable Nullifying