On Thursday 28 March 2002 05:20, Erik Price wrote:
> On Wednesday, March 27, 2002, at 04:11  PM, Matt Friedman wrote:
> > When you have all your items in an array use implode to add a character
> > in between every item.
> >
> > $str = implode($yourArray, $separator);
> >
> > This will add the separator to the end of each string except the last
> > one.
>
> I like that idea, but I don't think it would work in this case -- for
> one thing, the array is a pointer to a mysql_fetch_assoc() result, so I
> am not sure how to implode that (not saying it can't be done), and for
> another, I would have to explode the array again and would lose the
> separator.
>
> Unless... unless I were to implode with say, a bogus separator AND a
> 'real' separator, and then explode using only the bogus separator
> (leaving the 'real' separator hanging onto the end of each element).
>
> This seems like it could work, but in a complex array like a
> mysql_fetch_assoc() result, I'm not sure how to implode.

All this imploding and exploding would probably eat lots of memory and CPU 
time if you have a large amount of data.

What I do is just remove the extra bits after the while loop has finished.


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
I base my fashion taste on what doesn't itch.
                -- Gilda Radner
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to