title: Get returned array values from object into variable PHP
body: <p>I'm quite new to OOP PHP and I've wrote a class to get Lat/Long from Google's map API. This is kinda irrelevant as that works fine.</p>
  
  <p>From the class I return an array of the LAT/LONG/ADDRESS values as seen below:</p>
  
  <pre><code>    class latLngFinder {
  
      /**
      * Creates cURL connection to Google API v3
      * @param string $url The URL to read from
      * @return string The URL content
      */
      private function getURL($url){
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
          curl_setopt($ch, CURLOPT_HEADER, 0);
          curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
          curl_setopt($ch, CURLOPT_URL, $url);
          $tmp = curl_exec($ch);
          curl_close($ch);
          if ($tmp != false){
              return $tmp;
          }
      }
  
      /**
      * Get Latitude/Longitude/Formatted Address based on an address
      * @param string $address The address for finding coordinates
      * @return array An array containing Latitude/Longitude/Formatted Address
      */
      public function findCoord($address){
          $address = str_replace(' ', '+', $address);
          $url = 'http://maps.googleapis.com/maps/api/geocode/xml?address=' . $address . '&amp;sensor=false';
          $data = $this-&gt;getURL($url);
          if ($data){
              $xml = new SimpleXMLElement($data);
              $status = $xml-&gt;status;
  
              // Use this to debug returned XML
              //print_r($xml);
  
              if ($status == 'OK'){
                  // Find Latitude/Longitude/Formatted Address in XML
                  $lat = array( (string) $xml-&gt;result-&gt;geometry-&gt;location-&gt;lat);
                  $lng = array( (string) $xml-&gt;result-&gt;geometry-&gt;location-&gt;lng);
                  $formatted_addr = array( (string) $xml-&gt;result-&gt;formatted_address);
  
              }
          }
          // Return data
          return array('formatted_address' =&gt;  $formatted_addr[0], 'lat' =&gt; $lat[0], 'lng' =&gt; $lng[0]);
  
      }
  
  
  };
  </code></pre>
  
  <p>When I create the class object:</p>
  
  <pre><code> // Include class
      require_once(dirname(__FILE__) . '/class.latLngFinder.php');
  
      // Initialise the latLngFinder class
      $obj = new latLngFinder();
  
      print_r($obj-&gt;findCoord($row['address']));
  </code></pre>
  
  <p>I want to get the array that was returned from the class, this is where I am stuck. I've tried using:</p>
  
  <pre><code>$var = print_r($obj-&gt;findCoord($row['address']), true);
  </code></pre>
  
  <p>However this returns the array as a string which I do not want. Can anyone help?</p>
  
  <p>Thanks.</p>