eval.in

Paste #4708

PHP — PHP 5.4.6, pasted 1 year ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<?php

$names = array( "Ayush" , "Vaibhav", "Shivam", "Hacker", "Topper",
                "ABCD",  "NameR", "Tammi", "Colgate", "Britney",
                "Bra", "Kisser");

$addthis = "ADDTHIS";

$result = call_user_func_array(
    'array_merge', array_map(function($v) use ($addthis) {
        return $v + [10 => $addthis];
    }, array_chunk($names, 10))
); array_pop($result);

print_r($result);

Program Output

Array
(
    [0] => Ayush
    [1] => Vaibhav
    [2] => Shivam
    [3] => Hacker
    [4] => Topper
    [5] => ABCD
    [6] => NameR
    [7] => Tammi
    [8] => Colgate
    [9] => Britney
    [10] => ADDTHIS
    [11] => Bra
    [12] => Kisser
)

OK (0.004 sec real, 0.006 sec wall, 13 MB, 161 syscalls)

Fork