PDA

View Full Version : مبتدی: پیاده سازی تابع Rnge



milad.biroonvand
پنج شنبه 19 آذر 1388, 12:06 عصر
اگر بخواین کد این تابع رو بنویسین ، به این صورته :



<?php

$num=my_range(10,12);

echo $num[0];
echo $num [1];
echo $num [2];

function my_range( $start, $end, $step = 1)
{
$a = array();
$count=0;
for($i = $start;$i<= $end;$i++)
{
$a[$count]=$i ;
count++;
}
return $a;
}
?>