Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8821169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:47:09+00:00 2026-06-14T05:47:09+00:00

I have an array with user information and a web service on a site

  • 0

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.

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.

$users = array
(  
  "username"=>array("Fullname","Status"),  
  "johndoe"=>array("John Doe","Online"),
  "janedoe"=>array("Jane Doe","Offline")
);

This is an example of the url I can use to query the site (the query returns only the users status (Online or Offline):
http://thesite.com:80/webservice/user/username/

This is the code I can use to get a specific user status:

$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

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.

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.

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:47:10+00:00Added an answer on June 14, 2026 at 5:47 am

    If your $users array don’t changes, you can do this:

    foreach($users as $username=>$userdata) {
        $url = 'http://thesite.com:80/webservice/user/'.$username.'/';
        $get = fopen($url, "r");
        if ($get) {
            while (!feof($get)) {
                $state = fgets($get, 4096);
            }
            fclose($get);
        }
        $users[$username][1] = $state;
    }
    

    If you can change your $users array to be associative like this:

    $users = array(  
        "username"=>array("fullname"=>"Fullname","status"=>"Status"),  
        "johndoe"=>array("fullname"=>"John Doe","status"=>"Online"),
        "janedoe"=>array("fullname"=>"Jane Doe","status"=>"Offline")
    );
    

    That would let you use more key/values and a bit safer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My C# web app requires the user to enter automobile information. The user can
I have an array of user inputs ($atts) as key=>value pairs. Some of the
I am using PHP and I have an array of user images that I
I have the code: $getCookieData = $this->Cookie->read('data'); $getUser = $this->User->find('first', array('conditions' => array('User.username' =>
i have created Array of Linkbutton and when user click on link button it
I have this code: var a:Array = [ Ramsey, Tusey, Iuser,Sephora,'user', 'reseo', 'nesey', 'sela']
I have array of hashes: @array = [{:id => 1, :status=>R}, {:id => 1,
I am trying to build a db driven web site in which the user
I have a function which must return one dimensional associate array, like $user_info[$index]=value where
I have a web service which you post data to and it returns you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.