PHP Tutorials

How to get week dates from week number and year

In this tutorial I will show you how to get week dates from week number and year. We will calculate ISO week number (1-53) and represent the start of the week “Monday”. There is a setISODate() method with DateTime extension that accepts the year (4-digit year) and ISO week number. Example of get week dates from week number and year The output of above code is following:  

How to capture screenshot of website from URL in PHP

In this tutorial, I will show you how to capture screenshot of any website from URL in PHP. There are so many third party APIs are available to capture screenshot of the website using PHP script. In the following example, I am using Google API to capture screenshot from given url. You can easily capture the screenshot using Google APIs. There are many reason to capture screenshot of website to …

Continue reading

How to Remove Special Character from String in PHP

In this tutorial I will show you how to remove special character from string in PHP. Sometimes we need to remove all special characters by using preg_replace from input string. There are two option available to remove special character from string using php. Option 1: Using preg_replace PHP Function We can remove special character from sting using preg_replace, it’s using regular expression to special character from string. Syntax of preg_replace …

Continue reading

How to Remove Duplicates from Multidimensional Array

In this tutorial I will show you how to remove duplicates from multidimensional array in PHP. array_unique() function works on single dimensional array not on multidimensional arrays. After googling I have found a way to get unique multidimensional array using serialization of array. Serialization is used to storing or passing PHP values around without losing their type and structure. Steps to remove duplicates from multidimensional array 1. We will use …

Continue reading

Create Dynamic Tree View Menu with PHP, MySQL, CSS

In this tutorial I will describe how to create dynamic tree view menu with PHP, MySQL, CSS. If you want to display menu items as a tree view structure following tutorial will help you. Steps to generate tree view menu: Step 1: First we need to create a table ‘items’ in MySQL database. This table contains four column, The column id is the item id and name is the item …

Continue reading

How to use the PHP Ternary Operator

In this tutorial I will show you how to use the PHP ternary operator. PHP Ternary operator logic is the process of using “(condition) ? (true return value) : (false return value)” statements to shorten your if/else structures. It is called the ternary operator because it takes three operands – a condition, a result for true, and a result for false. Following example with if/else logic: Ternary Operator Ternary operator …

Continue reading

PHP Interview Questions and Answers Set – 5

In this tutorial we are providing some set of frequently asked PHP Interview Questions for experienced candidates which will help them to get success in interview. Read PHP Interview Questions and Answers Set – 4. What is the difference between ereg_replace() and eregi_replace()? The function eregi_replace() is identical to the function ereg_replace() except that it ignores case distinction when matching alphabetic characters. Is it possible to protect special characters in …

Continue reading