PHP Array Operators

What are the Array Operators?

Explanation

Following are the Array Operators in PHP
Example Name Result
$a + $b Union Union of $a and $b.
$a == $b Equality TRUE if $a and $b have the same key/value pairs.
$a === $b Identity TRUE if $a and $b have the same key/value pairs in the same order and of the same types.
$a != $b Inequality TRUE if $a is not equal to $b.
$a <> $b Inequality TRUE if $a is not equal to $b.
$a !== $b Non-identity TRUE if $a is not identical to $b.

The + operator appends elements of remaining keys from the right handed array to the left handed.

If there is an array "a" having values "red", "green", and an array "b" having values "blue", "orange","pink" when we use "+" operator to add these two arrays like "c=a+b", the array c will have values "red", "green","pink".

But when these two arrays are added like "c=b+a", the array c will have values "blue", "orange","pink".

PHP Topics


Ask Questions

Ask Question