Chapter 6
Working with Files and Directories
In This Chapter
Saving to text files
Reading from text files
Reading a file as an array
Parsing delimited text data
Working with file and directory functions
An important part of any programming language is file manipulations. Whether you need to create a comma-separated value (CSV) file or generate a dynamic list of files in a directory, or just need a semi-permanent place to log records on the server, file manipulation functions are an indispensable part of your PHP toolbox.
Text File Manipulation
Work with text files is split into two basic categories: writing and reading. Writing and reading come down to six basic functions. See the following bullet list for a brief explanation of the six basic file functions. Each function has an entire subsection in the following “Writing text to files” and “Reading from the file” sections:
- fopen(): Stores a connection to a file you specify in a variable you specify
- fwrite(): Writes text you specify ...
Get HTML5 and CSS3 All-in-One For Dummies, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.