Where are you looking to load your file from, is it stored locally on your computer or is it on the server?Javascript can't read local files from the users computer unless you use a form with a file input and HTML5. Even then it is a bit hit and miss as some browser do not support the required functions.
If you want to load a file form the server you can use the XMLHttpRequest object and get the responseText or responseXML, depending on the format of the data.
Once you have the data loaded in either of these ways you can use arrays and string splitting just like you would in PHP, although Javascript is considerably less reliable and fast as PHP.
var fileArray = string.split('\n')
You'll want to use the 'For Netscape 6' one from that page, the other two use techniques that have been superseded and do not work on all browsers.this might work: http://www.rgagnon.com/jsdetails/js-0034.html
<script type="text/javascript">
var filePath = PATH_TO_FILE e.g. http://www.google.com/file.txt
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET",filePath,false);
xmlhttp.send(null);
var fileContent = xmlhttp.responseText;
var fileArray = fileContent.split('\n')
//Now do whatever you need with the array
</script>
a JS function which does what the PHP function file() does. I want to read a file to a string or array.