我已经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-")
)?
感谢