I have two functions that print some values. I need to use the variable $mv in the second function. However, $mv can only be defined in the first function. I have tried all types of PHP global examples and none of them has allowed the $mv variable to be used or visible or accessible in the second function.
function printMobilePrev(&$mobileprevresults) { if (count($mobileprevresults->getRows()) > 0) { $mv = $mobileprevRows[0][0]; $mobileprevRows = $mobileprevresults->getRows(); echo '<p>Previous period (sessions): '.$mobileprevRows[0][0].'..............................'; } else { print '<p>No results found.</p>'; } } function printMobileCurr(&$mobilecurrresults) { if (count($mobilecurrresults->getRows()) > 0) { $mobdiff = ($mobcur - $mv); $mobpctchg = ($mobdiff / $mobprev) * 100; $mobilecurrRows = $mobilecurrresults->getRows(); echo '<p>Previous period (sessions): '.$mobileprevRows[0][0].'..............................'; echo '<p>Previous period (sessions): '.$mv.'..............................'; echo '<p>Current period (sessions): '.$mobilecurrRows[0][0].'..............................'; if ($mobdiff > 0){ echo '<p>Percent increase: '.$mobpctchg.'..............................'; } else { echo '<p>Percent decrease: '.$mobpctchg.'..............................'; } } else { print '<p>No results found.</p>'; } }