Best Resources and Tutorials to Learn Web Development

Tutorialio aims to be the first and last website you have to visit when looking for answers to common programming questions. We will try to post answers to one frequently asked question everyday so keep visiting. Here is a list of our recently published tutorials.

Best way to strip all whitespace characters in a string in PHP

Many times, the strings that you are manipulating in a PHP project will have extra spaces that need to be removed. For instance, you might want to replace multiple spaces with a single space or you might want to get rid of all the whitespace in a string. Similarly, you might be planning on stripping all the whitespace from either the left or the right end of a string. In this tutorial, you will learn about different techniques to do all that quickly and efficiently.

Best way to replace all occurrences of a string in JavaScript

JavaScript has a lot of useful methods that you can use to manipulate strings. For example, there is a String.replace() method to replace a simple substring with another string. One problem with this method is that it only replaces the first occurrence of the word or substring. In this tutorial, we will learn about different methods which can be used to replace all occurence of a substring inside the main string.

Best way to resize an image programmatically in PHP

If you are working on a website or project which deals with images, there will most probably come a time when you will have to programmatically resize those images. Maybe you have to create three different sizes of the same image to serve on different devices. Maybe you need to resize images that your users are uploading. Loading a 1920*1080 image when 96*54 image will do is just a waste of resources.

In this article, we will write different functions that will make use of the PHP’s GD library to resize images in PHP. GD has all the necessary functions to manipulate images so you won’t have to use any other 3rd party library.

Best way to check if a string starts with given word or substring in PHP

When looking for a word, character or substring inside another string, it is very common to check if the main string starts with given substring. Basically, every technique that worked when looking for a subtring inside another string will also work when we need to check if the substring only occurs at the beginning. However, this is a more specific situation and we can perform the check more efficiently using slightly different methods. In this tutorial, you will learn about different methods which can be used to check if a string starts with given word or substring.

Best way to remove or delete empty array elements in PHP

Many times, when working on a PHP project, you deal with an array which has some unwanted or empty array elements. This is especially true if you have no control over the values populated into the array. For example, you might have to store user input into an array and some of that input might contain unwanted empty strings. In this tutorial, you will learn about different methods which can be used to remove empty elements from an array. We will also learn how to remove other elements with a specific value.

Best way to get the full URL or query string of current page in JavaScript

Every now and then you will want to get the full URL of current page in a project you are working on. Fortunately, JavaScript allows us to get different parts of a URL or the complete URL as a unit. In this post, you will learn about different properties of the Location object returned by window.location property. Each of these properties can either return the full URL or a part of it.

Best way to insert an element at a specific position in an array in JavaScript

In one of my previous posts, I mentioned different ways to remove or delete a specific element from an array in JavaScript. When manipulating arrays, the need to insert elements at a specific index is just as common. There are multiple ways to insert elements into an array. Each of these methods has its own pros and cons. This tutorial will teach you how to choose the best method to insert elements in an array using JavaScript in certain situations.

Best way to check if an element is hidden or visible in JavaScript

Using JavaScript or jQuery to check if an element is hidden or not sounds very simple. However, there are lot of things that you need can determine the final outcome of such a check. For instance, everyone will have a doing criteria for determine if an element is hidden or visible.

In some projects, an element could be considered hidden only if its display property is set to none. In other projects, the element would be considered hidden if its opacity is set to 0 or its visible property is set to hidden. In this post, we will discuss how to determine the visibility of an element based on all these properties.

Best way to add remove toggle and replace classes of an element in JavaScript

Almost all website projects that we work on require us to change the classes of different HTML elements at one time or other. We can do this very easily using jQuery. However, using a library just to change or manipulate the classes of different DOM element is overkill. In this post, we will cover different methods to achieve all this using pure JavaScript.

Best way to remove first or last characters from a string in PHP

Every now and then, we have to deal with strings which contain unwanted characters either at their beginning or the end. PHP provides a lot of methods which can be used to remove these characters. Each of them has its advantages and disadvantages. In this tutorial, we will discuss all these methods in detail so that you can choose the one that works best for your situation.

Best way to calculate the difference between two dates in PHP

Calculating the difference between two dates is not as easy as it sounds. There are a lot of things that can go wrong if you are not careful. For example, you have to take both leap years and daylight saving time into consideration. Simply converting two dates to a timestamp and subtracting the values is not reliable in all cases.

Fortunately, the PHP DateTime class takes care of all this for us. In this tutorial, we will use the different methods from this class to get the difference between two dates.

Best way to get the current date and time in JavaScript

There are a lot of scenarios where you might want to get the current date and time in JavaScript. For instance, you might be creating a website where you want to change the theme based on time of the day like setting a dark theme at night or you might simply want to display the current time and date to users.

In this tutorial, you will learn how to use the Date object and its methods to get all the necessary information about the current date and time.

Best way to check if a string contains a specific word or substring in PHP

Let’s say you have a string and and you want to check if it contains a specific word, character or substring. This can be done with the help of strpos(), regular expressions, strstr() and a few more functions. In this article, we will discuss the pros and cons of each of these methods in detail.

Best way to redirect to another webpage in JavaScript

There are many situations where you might want to redirect users to a different page based on some action they took. For example, if the users deleted a post, you might want to redirect them to the homepage after deletion. In this tutorial, you will learn about different methods that can be used to redirect users to another page with pure JavaScript. You don’t need to use jQuery for simply redirecting users to another webpage.

Best way to read a large file line by line in PHP

Every now and then, you will have to read and process a large file in PHP. If you are not careful when reading a large file, you will often end up exhausting all the memory of your server. However, there is no need to worry because PHP already provides a lot of inbuilt functions to read large files (by large I mean files with size over 1GB) either line by line or one chunk at a time. In this article, you will learn about the pros and cons of all these techniques.

Best way to get the current timestamp in JavaScript

As a developer, every now and then, you will need to get the current timestamp in JavaScript. It allows us to represent both the current date and time as a single number. There are many ways to get the current timestamp or epoch time or number of seconds since January 1, 1970 00:00:00 UTC.

In this tutorial, we will discuss all these methods along with their pros and cons in detail.

Best way to delete an element from an array in PHP

Let’s say you have an array and you want to delete one or more elements from that array using PHP. Maybe you have to delete an element with a specific value or maybe you have to delete multiple consecutive elements. In this article, you will learn about different inbuilt PHP functions that can help you remove one or more elements based on their key or value.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top