adrian28uk Posted May 15, 2007 Share Posted May 15, 2007 How do I pull information from one of the fields in my database and put this into an array. The information in the field is stored as follows with a comma between each number 1342,1873 I need to get these numbers in to the array, then after this I can pass each value and check this against another table in my database. I tried $arr=array($row['numbers']); and of course it did not work. I need it so when pulled from the database it formats like below $arr=array("1342","1873"); foreach ($arr as $value) { // rest of code // } Thank you Link to comment https://forums.phpfreaks.com/topic/51493-pulling-database-value-in-to-array/ Share on other sites More sharing options...
MadTechie Posted May 15, 2007 Share Posted May 15, 2007 explode <?php // Example 1 $pizza = "piece1,piece2,piece3,piece4,piece5,piece6"; $pieces = explode(",", $pizza); echo $pieces[0]; // piece1 echo $pieces[1]; // piece2 ?> Link to comment https://forums.phpfreaks.com/topic/51493-pulling-database-value-in-to-array/#findComment-253592 Share on other sites More sharing options...
adrian28uk Posted May 15, 2007 Author Share Posted May 15, 2007 Yes that worked, so I used explode and then put this information in to the array. Link to comment https://forums.phpfreaks.com/topic/51493-pulling-database-value-in-to-array/#findComment-253618 Share on other sites More sharing options...
MadTechie Posted May 15, 2007 Share Posted May 15, 2007 Well kinda explode will create the array for you Link to comment https://forums.phpfreaks.com/topic/51493-pulling-database-value-in-to-array/#findComment-253699 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.