-1

so i have this array;

Array ( [0] => A [1] => B [2] => C ) 

what i want to do is;

Array ( [0] => A [1] => A [2] => A [3] => B [4] => B [5] => B [6] => C [7] => C [8] => C)

repeat each value, A-A-A-B-B-B-C-C-C

i have tried array_merge and gives me A-B-C-A-B-C

thanks!

4

1 回答 1

2
$orig = array('A', 'B', 'C');

$new = array();
foreach ($orig as $item) {
    $new[] = $item;
    $new[] = $item;
    $new[] = $item;
}
于 2013-02-03T00:15:19.803 回答