Append string to every element in an array
Posted: Mon Aug 16, 2004 7:16 pm
I have an array:
Is there away to append a string to the beginning of each element without looping through each value?
I can do it like this I just have a dozen or so arrays and I don't want a dozen or so more loops.
Any suggestions?
Code: Select all
<?php
$a_name = ('james','mike','keith','dan'.......);
?>I can do it like this I just have a dozen or so arrays and I don't want a dozen or so more loops.
Code: Select all
<?php
foreach($a_name as $val){
$a_name[] = 'Before '.$val;
}
?>