|
Posted by Peter Jay Salzman on 11/16/35 11:31
Consider:
$myHobbits = array( 'frodo', 'bilbo', 'merry', 'pippin' );
I'd like generate the string:
"frodo, bilbo, merry, pippin"
One way of doing this would be:
$str = '';
foreach ( $myHobbits as $hobbit )
$str .= "$hobbit, ";
$str = rtrim( $str, ", " );
Does anyone know how to do this in less than 4 lines of code?
Thanks!
Pete
Navigation:
[Reply to this message]
|