RichieW13 Posted September 2, 2011 Share Posted September 2, 2011 Is there any limit to the length of an array element in a flat data file? For instance, I have a flat file that I might end up having 200 rows, with each row containing 15 elements. Most of the elements will be about 20 characters or less, but a couple of the elements might be 300-400 characters. I'm guessing there is no limit. And since each row will be longer than one "line" in a .txt file, how best to mark the end of a row? [i assume that using a database is probably the better way to do this, but on this particular website I'm working on that isn't an option.] Quote Link to comment https://forums.phpfreaks.com/topic/246288-php-data-file-array-element-length/ Share on other sites More sharing options...
freelance84 Posted September 2, 2011 Share Posted September 2, 2011 http://en.wikipedia.org/wiki/Comma-separated_values There is no (as far as i am aware) limit to the number of characters single line within a txt file. Therefore the end of the line can be found with $lineValues = explode("\n",$txt); Quote Link to comment https://forums.phpfreaks.com/topic/246288-php-data-file-array-element-length/#findComment-1264805 Share on other sites More sharing options...
RichieW13 Posted September 2, 2011 Author Share Posted September 2, 2011 http://en.wikipedia.org/wiki/Comma-separated_values There is no (as far as i am aware) limit to the number of characters single line within a txt file. Therefore the end of the line can be found with $lineValues = explode("\n",$txt); So does that mean I should actually end each row with \n in the text file? like this: 2004,Ford,Escort,150000 miles\n Quote Link to comment https://forums.phpfreaks.com/topic/246288-php-data-file-array-element-length/#findComment-1264812 Share on other sites More sharing options...
jamesxg1 Posted September 2, 2011 Share Posted September 2, 2011 No, to my knowledge an array does not have a maximum limit. However, your hosting company will have a load time limit, so if your array is large breaking it down may exceed this limit, thus making the page exit. James. Quote Link to comment https://forums.phpfreaks.com/topic/246288-php-data-file-array-element-length/#findComment-1264824 Share on other sites More sharing options...
freelance84 Posted September 3, 2011 Share Posted September 3, 2011 Appologies, i copied that from a script i used on a textarea input. For just a file you can use: $myFile = "../myTextFile.txt"; $lines = file($myFile); print_r($lines); Quote Link to comment https://forums.phpfreaks.com/topic/246288-php-data-file-array-element-length/#findComment-1265059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.