niconico Posted November 15, 2006 Share Posted November 15, 2006 I'm trying to duplicate the following hard-coded array assignment by structuring a data file and reading it into an array.[code]$elements = array("group"=>"one","0"=>8,"1"=>5,"2"=>8,"3"=>7,"4"=>9,"5"=>8,"6"=>7,"7"=>7,"8"=>8,"9"=>8,"d"=>3,"c"=>3);[/code]I'm trying to find the fastest most efficient way of getting these values into an indexed array called $elements.Your suggestions are appreciated. Thanks... Link to comment https://forums.phpfreaks.com/topic/27340-efficient-file-to-array-procedure/ Share on other sites More sharing options...
kenrbnsn Posted November 15, 2006 Share Posted November 15, 2006 More information is needed before a meaningful answer can be supplied... :)Is the data static or can it change? Will the keys always be the same?Ken Link to comment https://forums.phpfreaks.com/topic/27340-efficient-file-to-array-procedure/#findComment-125009 Share on other sites More sharing options...
niconico Posted November 15, 2006 Author Share Posted November 15, 2006 The data would have to be considered static. The keys will always be the same. But there may be multiple files of this type, each with it's own data, which functions as kind of a configuration file. Link to comment https://forums.phpfreaks.com/topic/27340-efficient-file-to-array-procedure/#findComment-125041 Share on other sites More sharing options...
kenrbnsn Posted November 15, 2006 Share Posted November 15, 2006 Take a look at the [url=http://www.php.net/parse_ini_file]parse_ini_file()[/url] function. Ken Link to comment https://forums.phpfreaks.com/topic/27340-efficient-file-to-array-procedure/#findComment-125057 Share on other sites More sharing options...
niconico Posted November 15, 2006 Author Share Posted November 15, 2006 Yes, Ken, that's absolutely the ticket I was shopping for. Moreover, ini files are an established convention. The sections are great for organization and the parse_ini_file() is flexible.Thanks for getting that solution to me! Link to comment https://forums.phpfreaks.com/topic/27340-efficient-file-to-array-procedure/#findComment-125228 Share on other sites More sharing options...
yvees Posted November 19, 2006 Share Posted November 19, 2006 hi sorry dont really know how this site works.im not really replying ur post but was hoping u could help me with ideas for my school project anything thats web based in ay langueage prefarably html,php and mysql.thanx waiting for a reply Link to comment https://forums.phpfreaks.com/topic/27340-efficient-file-to-array-procedure/#findComment-127048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.