Alok Prasad has Published 52 Articles

How to convert an array to SimpleXML in PHP?

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 11:20:10

3K+ Views

We can solved the above problem using array_walk_recursive() function.array_walk_recursive()   is an inbuilt PHP function. This function converts array to XML document where keys of the array are converted into values and values of the array are converted into the element of XML.Let' demonstrate with a simple example.ExampleOutput ... Read More

How to call parent constructor in child class in PHP?

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 11:06:57

3K+ Views

We will face two cases while calling the parent constructor method in child class.Case1We can't run directly the parent class constructor in child class if the child class defines a constructor. In order to run a parent constructor, a call to parent::__construct() within the child constructor is required.Example Live DemoOutput: I ... Read More

How to convert XML file into array in PHP?

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 11:04:27

2K+ Views

To convert the XML document into PHP array, we have to utilize some PHP functions. The procedure is explained underneath with an example.Step 1We have to create an XML file that needs to convert into the array.abc.xml           AL       A   ... Read More

How to Check if PHP session has already started?

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 09:48:01

3K+ Views

In PHP, we utilize session_start() an inbuilt function to start the session .But the problem we face in a PHP script is if we execute it more than once it throws an error. So here we will learn how to check the session started or not without calling session_start() function ... Read More

Explain array_diff() in PHP

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 09:23:06

242 Views

PHP offers different kinds of inbuilt functions having particular functionalities. The array_diff() is a predefined function in PHP and is utilized to figure the distinction between at least two arrays. If we utilize this function with two arrays it returns an array containing every element from array1 that are absent ... Read More

Explain str_split() function in PHP

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 09:21:53

184 Views

PHP offers different kinds of inbuilt functions having particular functionalities. The str_split() is a predefined function in PHP and is utilized to convert the given string into an array.This function works in such a way that it parts the given string into smaller strings of length, the length is determined ... Read More

Explain array_map() function in PHP

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 09:20:55

236 Views

PHP offers various types of inbuilt functions to perform distinctive functionalities. The array_map() is an inbuilt function in PHP and it works with PHP array.This function works in such a way that it sends every component of an array to a predefined function and returns an array with new values ... Read More

Explain substr() function in PHP

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 09:19:10

182 Views

PHP offers different kinds of inbuilt functions having distinctive functionalities. The substr() is a built-in function in PHP and this function works with strings. It is utilized to extricate a part of the string .The syntax of the substr() is demonstrated below.substr(string, begin, length)Now let's discuss the Parameters. Three parameters ... Read More

Explain array_intersect() function in PHP.

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 08:57:27

164 Views

In this article, we will learn an array_intersect() a predefined PHP array function. This builtin function of PHP is utilized to figure the convergence of at least two arrays. The function is utilized to compare at least two arrays and returns the matches. The function prints just those components of ... Read More

What is Pass By Reference and Pass By Value in PHP?

Alok Prasad

Alok Prasad

Updated on 29-Jun-2020 08:51:12

4K+ Views

In this article, we will learn about pass by value and pass by reference in PHP. Now, let’s understand these two concepts in detail.In PHP generally, we followed to pass the arguments to the function with passed by value approach. We are following this practice because if the value of the ... Read More

Advertisements