Answers for "php range"

PHP
1

foreach range php

<?php
  
foreach (range(0, 12) as $number) {
    echo $number;
}

?>
Posted by: Guest on June-30-2020
1

range in php

<?php
  // range($start, $end [,$steps])
  $numbers = range(0, 5);
  print_r($numbers);
  // Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )
	
  $numbers2 = range(0, 5, 2);
  print_r($numbers2);
  //Array ( [0] => 0 [1] => 2 [2] => 4 )
  
  
  ?>
Posted by: Guest on July-22-2021
0

php range

function range($start, $end, int|float $step = 1) array
-------------------------------------------------------
Create an array containing a range of elements.
  
Parameters:
mixed--$start--First value of the sequence.
mixed--$end--The sequence is ended upon reaching the end value.
float|int--$step--[optional]--If a step value is given, it will be used as the increment between elements in the sequence. 
Step should be given as a positive number. If not specified, step will default to 1.
  
Returns: an array of elements from start to end, inclusive.
  
Example :
=========
  foreach ( range( 0, 60, 11 ) as $numbers ) {
	if ( $numbers > 0 ) {
		echo $numbers;
		echo PHP_EOL;
	}
}
Posted by: Guest on September-11-2021

Browse Popular Code Answers by Language