lifeson2112 Posted March 13, 2007 Share Posted March 13, 2007 hello, I am reading info from a tab-delimited text file and I was wondering if anyone knew how to get this concept to work. I am trying to store the entire table in a two dimensional array, but the way I'm doing it right now won't work. for($i=0; $i<$numrows; $i++) {$columnsvalue[i] = explode("\t",$newfile[i]);} does anyone else know how to better work with multi-dimensional arrays? Link to comment https://forums.phpfreaks.com/topic/42588-solved-multi-dimensional-arrays/ Share on other sites More sharing options...
emehrkay Posted March 13, 2007 Share Posted March 13, 2007 show us the pattern of a line in your file and show us the pattern you want the array in Link to comment https://forums.phpfreaks.com/topic/42588-solved-multi-dimensional-arrays/#findComment-206681 Share on other sites More sharing options...
per1os Posted March 13, 2007 Share Posted March 13, 2007 Your missing the $ before $i, that may be part of the problem. --FrosT Link to comment https://forums.phpfreaks.com/topic/42588-solved-multi-dimensional-arrays/#findComment-206685 Share on other sites More sharing options...
lifeson2112 Posted March 13, 2007 Author Share Posted March 13, 2007 Ok, here's what the field names for the demo tab file look like: prod_id name availability caption price sale-price I'm trying to get it so $columsvalue[0][0] returns "prod_id", $columnsvalue[0][2] returns "availability".... I am just confused on the syntax I need to use for storing info in 2-dimensional-arrays using loops. Link to comment https://forums.phpfreaks.com/topic/42588-solved-multi-dimensional-arrays/#findComment-206690 Share on other sites More sharing options...
lifeson2112 Posted March 13, 2007 Author Share Posted March 13, 2007 Sorry, frost posted while I was writing the above comment. Yeah, I'm stupid, I just forgot to put the $ in front of the i's. It works now though. thanks for the help. I feel like a moron for not checking more thoroughly first though. Link to comment https://forums.phpfreaks.com/topic/42588-solved-multi-dimensional-arrays/#findComment-206694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.