|
Posted by Ken Robinson on 11/16/85 11:31
Peter Jay Salzman wrote:
> 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?
$str = implode(',',$myHobbits);
Ken
Navigation:
[Reply to this message]
|