PHP - 重复的数组值

时间:2013-02-03 00:12:24

标签: php

所以我有这个数组;

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

我想做的是;

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

重复每个值,A-A-A-B-B-B-C-C-C

我已经尝试过array_merge并给了我A-B-C-A-B-C

谢谢!

1 个答案:

答案 0 :(得分:2)

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

$new = array();
foreach ($orig as $item) {
    $new[] = $item;
    $new[] = $item;
    $new[] = $item;
}