PHP | Check if a number is prime
Given a number, we need to check whether it is prime or not in PHP. General approach for prime check is discussed here. In this article we will learn about how to check if a number is prime or not in PHP....
read more
Maximum execution time taken by a PHP Script
One important aspect of PHP programs is that the maximum time taken to execute a script is 30 seconds. The time limit varies depending on the hosting companies but the maximum execution time is between 30 to 60 seconds. The user may get errors of maximum time limit exceeds due to some heavy import or export of files or program which involves sending mail to many recipients. To avoid the situation, you need to increase the execution time limit.This article describes how to change or control the maximum execution time of a PHP script.Prerequisite required: You have already a custom php.ini file set up in your application or a request has to be done to the owner who maintains it. If some of the PHP scripts take longer time then the server stops and throws an error:...
read more
Online Group Chat application using PHP
Prerequisites: Technical knowledge:...
read more
How to define an array of different generic types in TypeScript ?
In typescript, an array is a data type that can store multiple values of different data types sequentially. Similar to JavaScript, Typescript supports array declaration and there are multiple ways to do it....
read more
Convert an object to associative array in PHP
An object is an instance of a class. It is simply a specimen of a class and has memory allocated. Array is the data structure that stores one or more similar type of values in a single name but associative array is different from a simple PHP array. An array which contains string index is called associative array. It stores element values in association with key values rather than in linear index order.Method 1: Using json_decode and json_encode method: The json_decode function accepts JSON encoded string and converts it into a PHP variable on the other hand json_encode returns a JSON encoded string for a given value.Syntax:...
read more
PHP Form Processing
In this article, we will discuss how to process form in PHP. HTML forms are used to send the user information to the server and returns the result back to the browser. For example, if you want to get the details of visitors to your website, and send them good thoughts, you can collect the user information by means of form processing. Then, the information can be validated either at the client-side or on the server-side. The final result is sent to the client through the respective web browser. To create a HTML form, form tag should be used....
read more
How to copy a file from one directory to another using PHP ?
The copy() function in PHP is used to copy a file from source to target or destination directory. It makes a copy of the source file to the destination file and if the destination file already exists, it gets overwritten. The copy() function returns true on success and false on failure....
read more
PHP Check if two arrays contain same elements
In this article, we will see how to compare the elements of arrays in PHP, & will know how to apply to get the result after comparison through the examples. In PHP, there are two types of arrays, Indexed array and Associative array. In an Indexed array, the array elements are index numerically starting from 0 while in an Associative array, the array elements have named keys associated with them....
read more
Determine the first and last iteration in a foreach loop in PHP?
Given an array of elements and the task is to determine the first and last iteration in the foreach loop. There are many ways to solve this problem which are listed below:...
read more
PHP append one array to another
Given two array arr1 and arr2 and the task is to append one array to another array....
read more
How to send data of HTML form directly to JSON file?
The task is to send data of HTML form directly to JSON file....
read more
How to remove an array element in a foreach loop?
Use unset() function to remove array elements in a foreach loop. The unset() function is an inbuilt function in PHP which is used to unset a specified variable. The behavior of this function depends on different things. If the function is called from inside of any user defined function then it unsets the value associated with the variables inside it, leaving the value which is initialized outside it....
read more