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 7550615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:15:29+00:00 2026-05-30T10:15:29+00:00

I am using a php script to track my iPhones positions for a project.

  • 0

I am using a php script to track my iPhones positions for a project. The script I’m using can be found here on github. The issue I’m facing however is that it’s tracking to devices. My laptop AND my iPhone. I want it to track just the iPhone however I want the ability to easily switch between the two devices if need be; in other words I want priority to be given to track the iPhone then the laptop. So I’m thinking of using the “deviceClass” to determine what device to select but I have no idea how to add it into the file: class.sosumi.php Here’s the array output here:

    Sosumi Object
(
    [devices] => Array
        (
            [0] => SosumiDevice Object
                (
                    [isLocating] => 1
                    [locationTimestamp] => **
                    [locationType] => Wifi
                    [horizontalAccuracy] => 65
                    [locationFinished] => 1
                    [longitude] => **
                    [latitude] => **
                    [deviceModel] => MacBookPro7_1
                    [deviceStatus] => 200
                    [id] => **
                    [name] => **
                    [deviceClass] => MacBookPro
                    [chargingStatus] => 
                    [batteryLevel] => 0
                )

            [1] => SosumiDevice Object
                (
                    [isLocating] => 1
                    [locationTimestamp] => **
                    [locationType] => Wifi
                    [horizontalAccuracy] => 65
                    [locationFinished] => 1
                    [longitude] => **
                    [latitude] => **
                    [deviceModel] => FourthGen
                    [deviceStatus] => 203
                    [id] => **
                    [name] => **
                    [deviceClass] => iPhone
                    [chargingStatus] => NotCharging
                    [batteryLevel] => 0.5866984
                )

        )

   )

Any help with figuring out how to get this working would be appreciated. It seems easy but for some reason I can’t get it working.

Cheers!

  • 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-05-30T10:15:31+00:00Added an answer on May 30, 2026 at 10:15 am

    I’m not sure whether I’ve got your question clearly, but you need either:

    array_filter

    Which will allow you filter your array like this:

    // Reference is implicit (I've added & for you to see it)!!!
    // Be careful not to change your data
    functon filterCallback( SosumiDevice &$obj){ 
        return $obj->deviceClass == 'MacBookPro';
    }
    

    usort

    Sort array that first are MacBooks

    function usortCallback( SosumiDevice $a, SosumiDevice $b){
        static $order = array(
             'MacBookPro' => 1,
             'FourthGen' => 2,
             ...
        );
    
        $oA = isset( $order[ $a->deviceClass]) ? $order[ $a->deviceClass] : -100;
        $oB = isset( $order[ $b->deviceClass]) ? $order[ $b->deviceClass] : -100;
    
        // Maybe reverse order of operands will be necessary
        return $oA - $oB;
    }
    

    This adds values classes like this:

    • MacBookPro => 1
    • FourGen => 2

    Therefore when you add params like: MacBookPro, FourthGen

    It’s evaluated as: 1 - 2, which returns -1 => MacBookPro should be before FourthGen

    foreach loop

    Split devices to groups based on device type:

    $groups = array();
    foreach( $this->devices as $device){
        if( !isset( $groups[ $device->deviceType])){
            $groups[ $device->deviceType] = array( $device);
            continue;
        }
        $groups[ $device->deviceType] = $device;
    }
    

    You can achieve the same with array filter, this would be more effective if you need to get all groups, array_filter when you need just one gruop.

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

Sidebar

Related Questions

I have a simple php script on a server that's using fsockopen to connect
I have a PHP script that executes a .bat file using system(cmd /c C:\dir\file.bat);
I have a script that generates images from text using PHP. It's working fine
say a ruby script is running ruby.rb SOMEUSERID using PHP, how can i find
so I'm using the ga.php script you can download from google analytics. I modified
How can I track all pages of a domain using JavaScript in index.php. Like
Is it possible to make changes in mysql's my.ini file using PHP script?
i am using a php script to automate posts to twitter. the script to
I'm using a PHP script with SimpleXML to parse an XML feed. I have
i wanna using curl in php script and run it in command line mode.

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.