I have this PHP fragment:
<?php $colors = array('red','green','blue'); foreach ($colors as &$item) { $item = 'color-'.$item; } print_r($colors); ?>
Exit:
Array ( [0] => color-red [1] => color-green [2] => color-blue )
Is this a simpler solution?
(some php array function like array_insert_before_all_items($colors,"color-") )?
thanks
kubedan
source share