PHP for a given range and steps to generate an array of methods, PHP given step array _php tutorial

Source: Internet
Author: User

PHP generates an array of steps based on a given range and step, and PHP is given a step array


Given the start and end values, given a step value, you can generate an equal margin group.

function Array_range ($from, $to, $step =1) {  $array = array ();  for ($x = $from; $x <= $to; $x + = $step) {    $array [] = $x;  }  return $array;} Print_r (Array_range (0, 5));/*returns:array (  [0] = 0  [1] = 5  [2] =  [3] =  [4] ] = 20) */

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/1019451.html www.bkjia.com true http://www.bkjia.com/PHPjc/1019451.html techarticle PHP generates an array based on a given range and stepping array, given the start and end values given by PHP, given a step value, you can generate an equal margin group. F ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.