snippets

Tracking Web Vitals in Google Analytics

There are a few different ways to track Web Vitals, however the easiest way is using the web-vitals JavaScript library. In this post we will load the web-vitals directly from CDN and use that to track the Core Web Vitals (LCP, FID, CLS) and other Web Vitals (FCP, TTFB) metrics.   Track Web Vitals in …

Tracking Web Vitals in Google Analytics Read More »

How to add custom nodes to WordPress RSS feed

Recently I was working on a WordPress site and wanted to add a custom node to the WordPress RSS Feeds. In my previous post How to add featured image to WordPress RSS feed we saw how to add a featured image to the post content in RSS Feed. In this post we will see how …

How to add custom nodes to WordPress RSS feed Read More »

How to create a zip file using PHP

Recently I had to write a script to create a zip file containing different files and folders. PHP has a ZipArchive class which can be used easily to create zip files. In this article we will see how to create zip files in PHP. We will create different zip files from different files and folders. …

How to create a zip file using PHP Read More »

How to create CSV file using PHP

CSV (comma-separated values) is one of the most popular methods for transferring tabular data between applications. Lot of applications want to export data in a CSV file. In this article we will see how we can create CSV file using PHP. We will also see how to automatically download the file instead of just showing …

How to create CSV file using PHP Read More »

How to sort a multi-dimension array by value in PHP

In this article we will see how to sort a multi-dimension array by value of one of the keys of the array. We can use a few different methods to do this. One way to to use usort() function. Another way is to just identify the values and create another array with the values and …

How to sort a multi-dimension array by value in PHP Read More »