Forum Moderators: coopster

Message Too Old, No Replies

making one row's info into an array

array help, data separated by commas

         

shudson250

10:10 pm on Sep 16, 2007 (gmt 0)

10+ Year Member



Hello,

I have a column in my table that i want to store id numbers that will corelate to another table. So one row will have a space that contains:
'55,56,58,62,73,103, etc...'
How do I take this information and split it up into an array, or at least make it useful so I can then take the numbers, and query those ID's on the other table to get the corresponding information?

Thanks!

cameraman

12:59 am on Sep 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to do separate queries, you can use explode [us2.php.net].
$idarray = explode(',',$idnumbers);

Alternatively, you could structure the other query to use the numbers in array format:
SELECT * FROM sometable WHERE thenumber IN ($idnumbers)

where $idnumbers is your comma delimited list.

shudson250

7:38 pm on Sep 17, 2007 (gmt 0)

10+ Year Member



Thanks cameraman! I've never used 'explode' before, and it's exactly what I need.
cheers,
s.

cameraman

8:57 pm on Sep 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're welcome!
Yep, explode and its counterpart implode are right handy functions.