On 26/Apr/2010, at 11:31 , chris burgess wrote:
> What's the tersest way to turn this -
>
> $temp = array(
> array( 'value' => 'one', ),
> array( 'value' => 'two', ),
> array( 'value' => 'three' ),
> ) ;
>
> into this -
>
> $str = 'one,two,three' ;
>
> I'm using
>
> foreach ( $temp as $t ) {
> $t2[] = $t['value'] ;
> }
> $str = implode(',', $t2);
>
> ... but my brain is nagging me that there's a one-liner.
Untested, but my brain says:
foreach ( $temp as $t )
$str .= sprintf("%s%s", (strlen($str))?", ":"", $t['value']);
(This is knee jerk, YMMV and I've not tested it.)
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]