Get variable from previous blog while using switch_to_blog

Your code, which I assume is in a function, should pass variables needed from the current blog. So, assuming that your code in your question is called by somefunction(), change that to pass along variables from the current blog, as in

// variables from the current blog
$current_blog_1 = "some value"
$current_blog_2 = "another value"
// do the code in the original question
somefunction ($current_blog_1, $current_blog_2);

It might even be more efficient to put current_blog values in an array, as in

// set some values before you call your code via a function
$current_blog_array = array();
$current_blog_array[] = "some value";
$current_blog_array[] = "another value";
// call the function with an array, empty if needed
somefunction ($current_blog_array = array());

Then process the array values in your original code.