Posts Tagged ‘PHP
Dec10Clear template cache in x-cart
Have you been making changing into a smarty template file (within x-cart and perhaps independently as well) for long and the changes would not come up at all? Who could tell better how frustrating this can be!
The simplest and most effective way to clear template cache in x-cart is to call cleanup.php file which is placed at the root directory of x-cart installation. So if your installation is inside public_html directory (have nothing to do with directory actually) and your website address is http://www.devarticles.in just call http://www.devarticles.in/cleanup.php and all your template cache will be cleared with a message something like this:
The compiled templates cache (“templates_c” directory) has been cleaned up.
(Thanks to Steve for his post)
Sep17Resetting array keys after unsettling a few of them
I have felt this need quite a few times in the past as well.
I have an array: Click to continue »
May27MYSQL custom sorting – order by field value
Yesterday i had a somewhat new (for me ) and different kind of requirement while displaying MySQL result on a page. I had a category menu in which masters and slaves were sorted alphabetically and in ascending order. Click to continue »
Apr02Spliting CSV (comma seperated) entry grouped by double quotes
By using fgetcsv function we can have well formatted output for csv data without any pain. If you don’t want to use fgetcsv function for some reason and your CSV comma separated entries may contain comma inside except the delimiters, here is a quick alternate. Click to continue »
Apr02To find mysql recodrs between specific date range based on start date and end date fields
While working on a report generation system i had to perform a query to check whether records exist in ‘reports’ table between a date range received from two form fields “start_date” and “end_date”. To make it more specific i will try to explain it with the help of an example. Click to continue »
Feb01Convert month name to month number in php
While working with a CJ run reports script i needed to convert “month name” into “month number” so i could store it in the database in date format. After doing some cleaning stuff i was ending with the month name, a three character string as “Jan”,”Mar”,”Apr” etc. Here is the quick work around i applied to get the month number automatically from the month name.
$month_name = "Jan"; //which i get from file name (Range_from_1_Jan_2009_to_3_Mar_2009.txt)
$month_number = "";
for($i=1;$i<=12;$i++){
if(strtolower(date("M", mktime(0, 0, 0, $i, 1, 0))) == strtolower($month_name)){
$month_number = $i;
break;
}
}
Now as php snippet code line 5 date(“M”, mktime(0, 0, 0, 1, 1, 0))) returns a three letter represantion of month name i get month “1″ if i pass $month_name=”Jan” and so on. If i had full month name like “January” i could make it work by replacing “M” with “F” where “F” format parameter is a full represantion of year name.
Special Note: Do not forget to see user comments down the page to find even smarter solutions





