php将变量存储到数组中

时间:2015-02-21 22:47:08

标签: php

我有很多想要存储到数组中的变量

$colors = array("red", "green", "blue", "yellow");

foreach ($colors as $value) {
    echo "$value <br>";
}

现在我希望将$ $值再次存入数组

p.s:看起来很愚蠢,但这是教育目的请不要告诉我为什么我已经做了$ colors array is exits

1 个答案:

答案 0 :(得分:0)

$colors = array("red", "green", "blue", "yellow");

foreach ($colors as $key => $value) {
    $value = strtoupper($value);
    $colors[$key] = $value;
}