PHP range

📔 : PHP 🔗

PHP range() function , pass किये गए start - end number के according elements का Array create करता है।

PHP range Syntax

range( string|int|float $start , string|int|float $end , int|float $step = 1 );

Parameters
  1. string | int | float $start | required : यह sequence values के लिए start input है , जो string / int / float type की।

  2. string | int| float $end | required : यह sequence values के लिए end input है , means जहाँ तक sequence end होगा ।

  3. int | float $step = 1 | optional : यह sequence value के लिए as a increment work करता है , या कह सकते हैं Array values के बीच difference . default value 1 होती है means values के बीच 1 number का difference होगा।

  4. Return Value : range() function दिए गए $start से $end तक दिए गए input के according Array return करता है।


PHP range Example

File : php_range.php

Copy Fullscreen Close Fullscreen
<?php 
  $num_array = range(1, 5);
  print_r($num_array);

  echo "<br />";

  $char_array = range('a', 'z', 3);
  print_r($char_array);
?>
Output
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)

Array
(
    [0] => a
    [1] => d
    [2] => g
    [3] => j
    [4] => m
    [5] => p
    [6] => s
    [7] => v
    [8] => y
)

? Example में <br> का use सिर्फ line break करने के लिए किया गया है।

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)

Get connected with me. :) LinkedIn Twitter Instagram Facebook