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

  • Home
  • SEARCH
  • 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 815985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:45:56+00:00 2026-05-15T01:45:56+00:00

So we got this function in PHP strcmp(string $1,string $2) // returns -1,0, or

  • 0

So we got this function in PHP

strcmp(string $1,string $2) // returns -1,0, or 1;

We Do not however, have an intcmp(); So i created one:

function intcmp($a,$b) {
    if((int)$a == (int)$b)return 0;
    if((int)$a  > (int)$b)return 1;
    if((int)$a  < (int)$b)return -1;
}

This just feels dirty. What do you all think?

this is part of a class to sort Javascripts by an ordering value passed in.

class JS
{
    // array('order'=>0,'path'=>'/js/somefile.js','attr'=>array());
    public $javascripts = array(); 
    ...
    public function __toString()
    {
        uasort($this->javascripts,array($this,'sortScripts'));
        return $this->render();
    }
    private function sortScripts($a,$b)
    {
        if((int)$a['order'] == (int)$b['order']) return 0;
        if((int)$a['order'] > (int)$b['order']) return 1;
        if((int)$a['order'] < (int)$b['order']) return -1;
    }
    ....
}
  • 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-15T01:45:56+00:00Added an answer on May 15, 2026 at 1:45 am

    Sort your data with:

    function sortScripts($a, $b)
    {
        return $a['order'] - $b['order'];
    }
    

    Use $b-$a if you want the reversed order.

    If the numbers in question exceed PHP’s integer range, return ($a < $b) ? -1 : (($a > $b) ? 1 : 0) is more robust.

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

Sidebar

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The issue you bring up about 'interact' not noticing that… May 16, 2026 at 11:32 am
  • Editorial Team
    Editorial Team added an answer Your example gives a blue link for me, as it… May 16, 2026 at 11:32 am
  • Editorial Team
    Editorial Team added an answer Take into account device memory as well. If you are… May 16, 2026 at 11:32 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I got this error when following this tutorial . Warning: require_once(...\sf_sandbox\apps\frontend\config\config.php) [function.require-once]: failed to
I need your help again. This should be a function for php. I've got
I have got the following issue, my function appends code to a string $string
I'm newbie with JQuery. I got this function function verify_at_bd() { var u =
I am developing a links voting site, and I have this function, to check
I got this error Fatal error: Call to a member function set_prefix() on a
I've finally got this PHP email script working (didn't work on localhost…), but my
I've got this odd problem. If I make a call on that function through
OK, so I've got this totally rare an unique scenario of a load balanced
I got this jQuery code which is working just fine. Except on element I

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.