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

The Archive Base Latest Questions

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

I have a script which is like a whois database. This function returns site

  • 0

I have a script which is like a whois database. This function returns site views and I want to echo between value.

How can I echo and return one result? If the number is say 4000, it should return only 1k-10k

Rows are like

1550330

1000000

The code:

$siteTotalViews=1000000;
if($siteTotalViews <= 100){
    echo '0-100';
}
if($siteTotalViews <= 1000){
    echo '100-1k';
}
if($siteTotalViews <= 10000){
    echo '1k-10k';
}
if($siteTotalViews <= 100000){
    echo '10k-100k';
}
if($siteTotalViews <= 1000000){
    echo '100k-1 mil';
}
if($siteTotalViews <= 2000000){
    echo '1 mil-2 mil';
}
if($siteTotalViews <= 5000000){
    echo '2 mil-5 mil';
}
if($siteTotalViews <= 10000000){
    echo '5 mil-10 mil';
}
if($siteTotalViews >= 10000000){
    echo '10 mil +';
}
  • 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-29T10:28:53+00:00Added an answer on May 29, 2026 at 10:28 am

    Quick fix:

    $siteTotalViews=1000000;
    if($siteTotalViews <= 100){
        echo '0-100';
    }
    //next else is new
    else if($siteTotalViews <= 1000){
        echo '100-1k';
    }
    //next else is new
    else if($siteTotalViews <= 10000){
        echo '1k-10k';
    }
    //next else is new
    else if($siteTotalViews <= 100000){
        echo '10k-100k';
    }
    

    Better fix:

    $names=array(
      100 => '0-100',
      1000 => '100-1k',
      10000 => '1k-10k',
      ...
    }
    
    foreach ($names as $count=>$name)
      if ($siteTotalViews<$count) break;
    
    echo $name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash script file which starts with a function definition, like this:
I have a script which creates a user-defined object like this: obj = new
I have a script which uses grep to output like this: 12 Apples 10
I have this PHP-script which I'd like to keep unchanged: $display = array( 'QDATETIME',
I have a script which has a DROP TABLE command like this: IF EXISTS
I have a simple test bash script which looks like that: #!/bin/bash cmd=rsync -rv
Currently I have a bash script which runs the find command, like so: find
I have put together a script which is very much like the flickr photostream
I have a Bash shell script in which I would like to pause execution
I have a small ruby script in which I'd like to use ActiveRecord to

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.