Home » 2015 » February

Implode() Function in PHP

PHP – Array implode The PHP function implode operates on an array and is known as the “undo” function of explode. If you have used explode to break up a string into chunks or just have an array of stuff you can use implode to put them all...
Continue reading »

Explode() Function in PHP

PHP –  Explode Function The PHP function explode lets you take a string and blow it up into smaller pieces. For example, if you had a sentence you could ask explode to use the sentence’s spaces ” ” as dynamite and it would blow up the sentence into...
Continue reading »

String Capitalization in PHP

PHP – String Capitalization Functions If you’ve ever wanted to manipulate the capitalization of your PHP strings, then this lesson will be quite helpful to you. PHP has three primary capitalization related functions: strtoupper, strtolower and ucwords. The function names are pretty self-explanatory, but why they are useful...
Continue reading »

Substring-Replace Function in PHP

PHP-Substring-Replace   substr_replace substr_replace — Replace text within a portion of a string Description mixed substr_replace ( mixed string, string replacement, int start [, int length] ) substr_replace() replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. The...
Continue reading »

String Replace Function in PHP

PHP String Replace Function Description mixed str_replace (mixed search, mixed replace, mixed subject) This function returns a string or an array with all occurences of search in subject replaced with the given replace value. If you don’t need fancy replacing rules, you should always use this function instead...
Continue reading »

File Upload in PHP

PHP File Upload Create an Upload-File Form. To allow users to upload files from a form can be very useful. Look at the following HTML form for uploading files: <html> <body><form action=”upload_file.php” method=”post” enctype=”multipart/form-data”> <label for=”file”>Filename:</label> <input type=”file” name=”file” id=”file” /> <br /> <input type=”submit” name=”submit” value=”Submit” />...
Continue reading »

File Truncate in PHP

PHP – File Truncate As we have mentioned before, when you open a file for writing with the paramater ‘w’ it completely wipes all data from that file. This action is also referred to as “truncating” a file. Truncate literally means to shorten. PHP – File Open: Truncate...
Continue reading »

File Append in PHP

PHP File Append So far we have learned how to open, close, read, and write to a file. However, the ways in which we have written to a file so far have caused the data that was stored in the file to be deleted. If you want to...
Continue reading »

File Delete in PHP

PHP – File Delete PHP – File Unlink When you view the contents of a directory you can see all the files that exist in that directory because the operating system or application that you are using displays a list of filenames. You can think of these filenames...
Continue reading »

Write/Read Function in PHP

PHP – Write/Read Function File Write Lets get on to the most useful part of file manipulation, writing. There is really only one main function that is used to write and it’s logically called fwrite. File Open : Write Before we can write information to our test file...
Continue reading »