mi hanno this PHP frammento:PHP: stringa Concatenate in tutti gli elementi di matrice
<?php
$colors = array('red','green','blue');
foreach ($colors as &$item)
{
$item = 'color-'.$item;
}
print_r($colors);
?>
uscita:
Array
(
[0] => car-red
[1] => car-green
[2] => car-blue
)
È soluzione più semplice?
(alcune funzioni php come quella array_insert_before_all_items($ colors,"car-")
)?
Grazie