Putting file contents into a string or array.
Say you have a file called data.xml and you want to put it into a string. There are two ways I know off hand to do this. You can use the function file() or file_get_contents.
file() returns the contents as an array.
file_get_contents returns the contents as a string.
file() can also return the contents as a string if you use the implode() function.
First, here's how to return the contents of data.xml as a string -- both ways.
or
This last example just converts the array into a string via implode().
Next is returning the contents of data.xml as an array.
My convention is to add a_ to the front of an array variable.
Also, there are other options like offsetting what is returned from the file. See the two links below for the syntax.
http://www.php.net/file » http://www.php.net/file-get-contents »