[pmwiki-devel] trim() snag...

Ben Wilson dausha at gmail.com
Fri May 11 06:10:55 CDT 2007


Try preg_split instead:

$i = preg_split("/\s*,\s*/", $data);

On 5/10/07, The Editor <editor at fast.st> wrote:
> Hit a snag trying to improve the routine I used to manage CSV's
>
> I use this routine to strip the extra spaces out of a CSV list like:
>
> Bob  ,  Joe, Dave  , Ed
>
>         $i = explode(",", $value);
>         foreach ($i as $ii) {
>                 $out[] = trim($ii);
>                 }
>         $value = implode(",", $out);
>
> Can anyone see what I'm doing wrong? It seems to be having no effect
> on the spaces...
>
> Cheers,
> Dan
>
> _______________________________________________
> pmwiki-devel mailing list
> pmwiki-devel at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-devel
>


-- 
Ben Wilson
"Words are the only thing which will last forever" Churchill



More information about the pmwiki-devel mailing list