Extract files from a .zip file using PHP
The unzip.php sample program below, extracts files from a ZIP archive. It uses the pc_mkdir_parents() function. The program also requires PHP's zip extension to be installed. You c
Read tutorialTHE TUTORIAL LIBRARY
The unzip.php sample program below, extracts files from a ZIP archive. It uses the pc_mkdir_parents() function. The program also requires PHP's zip extension to be installed. You c
Read tutorialThe zlib extension contains versions of many file-access functions, such as fopen(), fread(), and fwrite() (called gzopen(), gzread(), gzwrite(), etc.) that transparently compress
Read tutorialThe function parse_ini_file() reads configuration files structured like PHP's main php.ini file. Instead of applying the settings in the configuration file to PHP's configuration,
Read tutorialProcessing every word proceeds differently depending on how "word" is defined. The code in this recipe uses the Perl-compatible regular-expression engine's \s whitespace metacharac
Read tutorialYou want to count the number of lines, paragraphs, or records in a file.To count lines, use fgets(). Because it reads a line at a time, you can count the number of times it's calle
Read tutorialYou want to load the entire contents of a file into a variable. For example, you want to determine if the text in a file matches a regular expression. Use filesize()to get the size
Read tutorialWhen fopen() is passed a filename that begins with http://, it retrieves the given page with an HTTP/1.0 GET request (although a Host: header is also passed along to deal with virt
Read tutorialThe first argument to fopen()is the file to open; the second argument is the mode to open the file in. The mode specifies what operations can be performed on the file (reading and/
Read tutorialWhen embedded in a web server, PHP scripts usually do their job quickly and exit. This paradigm does not fit when using CLI; your scripts may run forever, or at least until the nex
Read tutorialpreg_split() can be used to split a string into substrings by using a regular expression match for the delimiters. PHP provides an explode() function that also splits strings, but
Read tutorialPHP's regular expression functions can also replace text based on pattern matching. The replacement functions can replace a substring that matches a subpattern with different text.
Read tutorialpreg_match() is the function that matches one pattern with the subject string and returns either true or false depending whether the subject matched the pattern. It also can return
Read tutorialOne example today. A better developer tomorrow.