For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > May 2007 > Re: [PHP-DB] Extracting data from Arrays in ISAM table









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Extracting data from Arrays in ISAM table
Stut

2007-05-20, 7:58 am

boclair@boclair.com wrote:
> I have a table with between 100k and 200k rows. One field, `names`, is
> populated, in each row, with an imploded array of up to 4 names.
>
> I require to create a list of names, without repeats, of all the names
> in `names` field to use in an html form.
>
> Any advise would be appreciated. I have no ideas on how to start.


The best option would be to normalise the data by breaking the names out
to a separate table. However, if that's not feasible my suggestion is
similar to that itoctopus sent, but a bit more memory efficient.

Inside the loop getting the records, do the following...

foreach (explode(',', $single_result['name']) as $name)
$arr_all_names[$name] = 1;

Then after the loop, to get an array of the names...

$arr_all_names = array_keys($arr_all_names);

-Stut
Starrats

2007-05-29, 8:02 am

http://Pamela-Anderson-in-nylons.in...p?movie=1673286
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com