我已經this PHP代碼片段:PHP的:字符串連接到所有數組項
<?php
$colors = array('red','green','blue');
foreach ($colors as &$item)
{
$item = 'color-'.$item;
}
print_r($colors);
?>
輸出:
Array
(
[0] => car-red
[1] => car-green
[2] => car-blue
)
它是簡單的解決方案?
(有些數組的php函數就像那個array_insert_before_all_items($ colors,"car-")
)?
感謝