AmitDiwan has Published 10744 Articles

PHP program to find standard deviation of values within an array

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 08:33:25

928 Views

To find standard deviation of values within an array, the code is as follows in PHP −Example Live DemoOutputThe standard deviation of elements in the array is 35.423156268181A function named ‘std_deviation’ is defined counts the number of elements in the array and initializes the variance to 0. The average is calculated ... Read More

PHP program to find missing elements from an array

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 08:32:02

1K+ Views

The ‘array_diff’ function can be used to find the elements that are missing from the array.Example Live DemoOutputElements missing from first array are Array (    [1] => 46    [2] => 47    [4] => 49    [5] => 50    [9] => 54    [10] => 55 ) Elements ... Read More

Removing duplicate elements from an array in PHP

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 08:30:36

824 Views

The ‘array_flip’ function can be used, that will reverse the values as indices and keys as values.Example Live DemoOutputThe original array contains Array (    [0] => 45    [1] => 65    [2] => 67    [3] => 99    [4] => 81    [5] => 90    [6] => ... Read More

Merging duplicate values into multi-dimensional array in PHP

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 08:18:46

788 Views

To merge duplicate values into multi-dimensional array in PHP, the code is as follows −Example Live DemoOutputThe unique array elements are Array (    [Cycling] => Array    (       [0] => Array       (          [Age] => 23          [name] ... Read More

HTML DOM console.trace() Method

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 08:14:34

267 Views

The HTML DOM console.trace() method is used to display the stack trace upto the point the console.trace() method has been called upon. It is basically used for displaying the code path i.e how the code ended up at that point.SyntaxFollowing is the syntax for console.trace() method.console.trace(label);Here, label is an optional ... Read More

Redirection in PHP

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 07:19:49

7K+ Views

The header function in PHP can be used to redirect the user from one page to another. It is an in-built function that sends raw HTTP header to the destination (client).Syntax of header functionheader( $header_value, $replace_value, $http_response_code)Following are the parameters −The ‘header_value’ in the function is used to store the ... Read More

The internal working of the ‘foreach’ loop in PHP

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 07:18:25

277 Views

The ‘foreach’ loop in PHP helps in accessing key value pairs within an array. The ‘foreach’ loop works with arrays only, with the advantage that a loop counter wouldn’t need to be initialized. In addition to this, no condition needs to be set that would be needed to exit out ... Read More

How to check if a string contains a specific sub string?

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 07:14:54

767 Views

To check if a string contains a specific substring, the ‘strlen’ and ‘strpos’ functions can be used. The ‘strlen’ gives the entire length of the string. The function ‘strpos’ finds the position wherein the substring occurs first in the string.Example Live DemoOutputThe substring is present within the string.Two strings are defined ... Read More

What are late static bindings in PHP?

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 07:11:33

1K+ Views

The basic idea behind late static bindings is that the concept of inheritance and the concept of ‘self’ keyword don’t follow the same rules. For example, a method ‘fun’ in parent class called in the child class won’t make ‘self’ refer to the child (as expected).The concept of late static ... Read More

What is the meaning and usage of ‘=&’ assignment operator in PHP?

AmitDiwan

AmitDiwan

Updated on 01-Jul-2020 07:10:22

846 Views

Instead of copying the data from one variable to another one, the changes made to an array or object can be made to another using the ‘=&’ operator. This is known as the ‘assignment by reference’ method, which means both the values or objects will point to the same data, ... Read More

Advertisements