You receive a data in form of string and it is supposed to be a valid JSON. So how to know whether a string you have is a valid JSON object. Here in this post I will show it with…
Category: PHP
Array Destructuring With or Without List Function in PHP
Have you been unwillingly using the useful “extract” function to convert array elements into their corresponding names with same variable name as the key of the array element? Have you been worrying about the non-friendly nature of your code for…
Creating Custom Shortcode in WordPress
With a lot of customization with the theme WordPress also provide us to create our own Custom Shortcode. Basically, shortcodes are the small piece of code which let user to add dynamic content in WordPress posts, pages or sidebar widgets.…
file_get_contents(): SSL operation failed with code 1 certificate verify failed
I got this error when I moved a site to new server. It was a simple file_get_contents() call to read an image file. If i copy pasted the url of the same file to open in browser it would open…
How to know the location of a function defined in PHP
Sometimes you want to know the location of a function defined in your php application. For example you are debugging a large online web application or website. To continue debug you want to enter into a function to debug. You…
How to Get Start & End dates of a Week by given Date
The following function gets start and end date of a week for a given date supplied in valid date string format. In the following function $week is the number of week in the year. For example the current week is…
How to know whether a file exists in URL using PHP
In PHP, to find whether a file exists in disk or on server we have: if(file_exists($filepath)) However is there a way to know whether a file exists in an url, such as, https://www.google.co.in/images/nav_logo242.png?
Create pdf preview thumbnail using php
Following the stackoverlow answer http://goo.gl/z9IWCB I did everything correct as mentioned in the answer to create pdf preview thumbnail using php but I struck with an error as such as this. error no decode delegate for this image format `\path\filename.pdf’…
Fully-formatted Time Difference between two Dates
An useful php function to calculate a time difference between two dates given in sql format. If the newer date is not passed as second argument it would calculate the different between the old date and current time. So it…
Create php array from select options
There are many ways to create a dropdown select options list from a given array in any programming language like PHP. Please check how to create a select list from a PHP array. However in this case I will make…