Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to find number between different ranges in php

// how to find number between different ranges in php
$number = 143;
$ranges = [
  "range1" => [
                "from" => 0,
                "to"   => 23
              ],
  "range2" => [
                "from" => 24,
                "to"   => 47
              ],
  "range3" => [
                "from" => 49,
                "to"   => 143
              ],
  "range4" => [
                "from" => 144,
                "to"   => 876000
              ],
];


foreach ($ranges as $key => $range) {

  if ( in_array($number, range($range['from'], $range['to']))) {
    return $key;
  }
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to set selected value in dropdown using php 
Php :: laravel route namespace and prefix 
Php :: how to change directory in command processor 
Php :: Remove images from the the_content() 
Php :: factorial program in php 
Php :: flexslider in laravel 5.8 
Php :: Jolt transform specification input 
Php :: WordPress oEmbed Funktion abschalten 
Php :: how to fetch data from database in php and display in pdf 
Php :: how to explode results from multi select form submitted 
Php :: str_pad in php 
Php :: chart trong laravel 
Php :: how get database structure in laravel 
Php :: keep track of view count php 
Php :: wp dev tehem support widget 
Php :: simple_html_dom stream does not support seeking 
Php :: x-default wpml canonical alternate hreflang 
Php :: RequestCriteria laravel 
Php :: php phalcon 
Php :: ipay generate hash id 
Php :: array filter vs array search php 
Php :: php endif endforeach endwhile 
Php :: custom middleware laravel 8 
Php :: Trying to get property 
Php :: codeigniter apache remove index.php 
Php :: error php 
Php :: how to print any string in double quotes in php 
Php :: laravel validation alphanumeric with spaces 
Php :: php get final redirect url 
Php :: convert string to int php 7 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =