array range function - generate an array of range values

array range function - generate an array of range values

array-range-example-in-php.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>array range function - generate an array of range values</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Md Iqbal Hosan">
  <meta name="title" content="array range function - generate an array of range values">
  <meta name="keywords" content="php, example, code, array, function, range">
  <meta name="description" content="array range function - generate an array of range values">
  <style>
   h2, h4{background:#bbb; color:#000098;}
   h2{ padding:3px; margin:3px; font-size:20px;}
   h4{ padding:2px; margin:2px; font-size:17px;}
   p{padding:2px; margin:2px; color:#003370;}
   body{ background:#FFFFFa;}
  </style>
 </head>
 <body>
  <h2>array range function - generate an array of range values</h2>
  <pre>
   <?php
    /*
     --------------------------------------------------------------
     lets describe and implement the range function
     range( lower bound, upper bound, step)
     --------------------------------------------------------------
    */
    $lowerBound = 2;
    $upperBound = 8;
    $step = 3;

    echo "<h4>Parameters to array range function</h4>";
    print "<p>$"."lowerBound = {$lowerBound}</p>";
    print "<p>$"."upperBound = {$upperBound}</p>";
    print "<p>$"."step = {$step}</p>";

    $myRangeArray = array();
    $myRangeArray = range($lowerBound, $upperBound, $step);
    echo "<h4>Output of myRangeArray using range() function</h4>";
    print_r($myRangeArray);
    /*
     -------------------------------------------------------------------------------------
     if step is not given it will take default 1
     -------------------------------------------------------------------------------------
    */
    $myRangeArray2 = range($lowerBound, $upperBound);
    echo "<h4>Output of myRangeArray2 using range() function without step</h4>";
    print_r($myRangeArray2);
   ?>
  </pre>
 </body>
</html>

array range function - generate an array of range values - output in the browser

No comments:

Post a Comment

leave your comments here..