title: PHP iterate multidimensional array - query web service every x seconds
body: <p>I have an array with user information and a web service on a site I can query for the status of a user (online/offline). What I would like to do is query the site every x seconds for the status of each user.</p>
  
  <p>There are about 10 users and belwois an example of the array. I can change the array is needed. Only thing I need to enter manually is the username and full name. The "status" I can call from the server.</p>
  
  <pre><code>$users = array
  (  
    "username"=&gt;array("Fullname","Status"),  
    "johndoe"=&gt;array("John Doe","Online"),
    "janedoe"=&gt;array("Jane Doe","Offline")
  );
  </code></pre>
  
  <p>This is an example of the url I can use to query the site (the query returns only the users status (Online or Offline):<br>
  <a href="http://thesite.com:80/webservice/user/" rel="nofollow">http://thesite.com:80/webservice/user/</a><strong>username</strong>/</p>
  
  <p>This is the code I can use to get a specific user status:</p>
  
  <pre><code>$url = 'http://thesite.com:80/webservice/user/johndoe/';
  $get = fopen($url, "r");
  if ($get) {
      while (!feof($get)) {
          $state = fgets($get, 4096);
      }
      fclose($get);
  }
  
  echo "User johndoe is: ".$status;
  // Output: User johndoe is: Online
  </code></pre>
  
  <p><strong>Now I only need help with iterating through the users and site every x seconds and update the array with each user status in the last array field for the user.</strong></p>
  
  <p><em>Please note that below I use php and fopen as this is a cross-domain get function and I could not get ajax/jquery to work. I do not have the option to modify the webservice server.</em></p>
  
  <p>Thanks :)</p>