does PHP have a function like matlab's linspace?

I want this to execute the following code in PHP

linspace(1,7,4);

I want to have linear array list as an output.

Answers


function linspace($i,$f,$n){
    $step = ($f-$i)/($n-1);
    return range ($i,$f,$step);
}

$test = linspace(0,3.14159,8);

print_r($test);

I have written my own in some minutes. Please test it out.


function range is your friend: http://php.net/manual/en/function.range.php

range(0, 12); //array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

Need Your Help

Writing text using canvas in HTML5

html5 canvas character-encoding html5-canvas

I have used the following code to write text using canvas.

Progressive Streaming Videoplayer

android video-streaming videoview

I am developing an application in which I have a list of videos to be downloaded from the URLs. Each video is of about 10 min duration. Now, what I want is that the video is downloaded progressivel...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.