You are not logged in.
Login
or
Register
.
JsPHP: a JavaScript library providing the PHP API
Home
Register
Demo
Categories
Functions
Contributors
Download
Links
Comments
FAQ
Contact
View
Edit
Benchmark
Revisions
Developers
Dependencies
Talk
Links
array_fill:
Edit: array_fill
Function:
array_fill
View array_fill
Edit array_fill
Edit code
Edit tests
Edit benchmark
View latest code
Edit latest code
Benchmark array_fill
Comment on array_fill
Comment on the latest code
View revisions
View versions
View contributors
View dependencies
View comments
View links
Download production code
Download development code
View the PHP docs
View phpjs.org
View phpjs.org raw code
Description:
Create an array containing num elements starting with index start_key each initialized to val.
Edit function
Code
:
function array_fill (start_index, num, mixed_val) { // http://jsphp.co/jsphp/fn/view/array_fill // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Waldo Malqui Silva // * example 1: array_fill(5, 6, 'banana'); // * returns 1: { 5: 'banana', 6: 'banana', 7: 'banana', 8: 'banana', 9: 'banana', 10: 'banana' } var key, tmp_arr = {}; if (!isNaN(start_index) && !isNaN(num)) { for (key = 0; key < num; key++) { tmp_arr[(key + start_index)] = mixed_val; } } return tmp_arr; }
You have to be logged in to edit functions.
Edit tests
Code
:
You have to be logged in to edit tests.
Edit benchmark
Code
:
You have to be logged in to edit benchmarks.
[
top
]
Comments
There are no comments yet, be the first!
Please
Login
or
Register
to post comments.