PHP:将数组输出存储在变量中以供以后使用

Script taken from http://css-tricks.com/snippets/php/get-geo-ip-information/

    .
    .                   
    .
             //Array where results will be stored
                       $ipInfo=array();

                       //check response from ipserver for above patterns
                       foreach ($patterns as $key => $pattern)
                       {
                               //store the result in array
                               $ipInfo[$key] = preg_match($pattern,$response,$value) && !empty($value[1]) ? $value[1] : 'not found';
                       }


                      return $ipInfo;
         }

This displays the $ipInfo.

The thing is that i don't want it to display $ipInfo. I want to save the output in a variable and then echo it later, when i need it in another place. How can i do that?

print_r(geoCheckIP($ip));

This is what's doing the outputting. Just assign to a variable instead:

$somevar = geoCheckIP($ip);

This is trivial PHP that you really should know.