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:
MySql find all tables with specific column/field name
December 8, 2014
How to look up in the entire DB and list out all tables which have specific column name or field name? Example belows looks for field `currency` from all database: To add specific database to the query, use:
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. […]
Javascript toggle show/hide div or anything
October 14, 2014
You would manipulate the elements by toggling between styling rather than changing the elements based on the innerHTML. In this case, you would toggle between display:none and display:block. Example:
jQuery(…).datepicker is not a function
October 7, 2014
The are several reasons for this error: 1.The jquery.ui is used before jquery. 2.The $ is used by another library. 3.The jquery lib that is referenced locally(wordpress) has different version from that using jquery.ui. 4.When the right library and version is referenced the browser cache must be cleared.
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
Recent Comments