[Phpmyadmin] Temporary disable phpmyadmin how to?

December 19, 2016

Phpmyadmin is an easy tools to have visualize interface to access database. If it is not in use, better to disable it to protect your site from hack or SQLInjection, You do not want to remove it, because in future it might be needed again, so just disable it in a simple way and enable […]

PHP get first day of current month, datepicker friendly

December 22, 2014

The simplest and readable way to do it is using this clean solution. All you need is a string represent the date. First day of the month: Last day of the month:

PHP script execution time tracking wallclock time

December 1, 2014

A simple way to find out execution time of php script without lots of calculation is tracks the wallclock time. Compare to tracking CPU time, it also include time that PHP is sat waiting for external resources such as disks or databases, which is not used for max_execution_time. Output: Execution time get user: 0.00023317337036133

PHP fgetcsv count lines end of file, eof

November 17, 2014

Due to fgetcsv read only a line from open file, or line by line if looping. As decribe below, it doesn’t able to return number of line from specific file. The fgetcsv() function parses a line from an open file, checking for CSV fields. The fgetcsv() function stops returning on a new line, at the […]

PHP check string exist in string

November 17, 2014

The correct way to write the statement to check if string contains specific words is use strpos function. Strpos is used to find the occurrence of one string inside other. Note that the use of !== false is deliberate; strpos returns either the offset at which the needle string begins in the haystack string, or […]

PHP dealing with commas in CSV data

November 12, 2014

Look carefully the data, there are multiple commas ‘,’ inside the address field. When transform the data to array, the output will be each commas separated in one array value. Example: (wrong way) Don’t attempt to do this with a regular expression. Just use str_getcsv()! The third parameter informs str_getcsv() to look for quote-enclosed fields. […]

PHP convert none png image to png format using GD

September 25, 2014

Based on what kind of image it is you could select the correct function to open the file. Then, you just need imagepng() to convert. Example:

PHP resize image using ratio

September 25, 2014

To maintain the aspect ratio of your original image, calculate the factor by which you have to resize the image in the vertical and horizontal direction. Example, resize image to 1920 max width or max height

PHP get image width & height

September 25, 2014

To get the width and height of the image use getimagesize(path_name), this function returns the array which contains the height, width, image_type constant and other image related info. By the following code you can achive that. See also PHP resize image using ratio

PHP delete file in directory

September 15, 2014

If to delete a single file, use the unlink() function. Unlink can safely remove a single file. That function will delete what you pass it as a parameter. For example, delete single file Delete multiple file in a directory, use loop: