PHP Tutorials

How to Remove Duplicate Values From Array in PHP using array_unique

In This PHP Tutorial We are going to learn how to remove duplicate values from array in PHP Programming Language.

The PHP built in function array_unique use to remove duplicate values from a PHP array. The PHP array_unique function takes an array as the input and returns a new array without duplicate values.

Continue Reading >>

How to Join Two Arrays in PHP using array_merge Function

In PHP array_merge() function is used to merge two or more arrays together.

In This Example we have two PHP arrays, $color1 and $color2. And we Combined $color1 and $color2 using php array_merge function.

$color1=array('Red','Green','Blue');
$color2=array('White','Black');
$result=array_merge($color1,$color2);
print_r($result);
Continue Reading >>

How to Generate Random Number in PHP 7

In this PHP 7 Tutorial you are going to learn How to get Random Number in PHP 7.

PHP 7 has introduced a new built in function called random_int() which will generate the random number between given two integers.

Continue Reading >>

How Remove Element from Array in PHP

PHP unset() function uses to remove element from array in PHP using array key.

Example 1

$fruits=array('Apple','Mango',''Orange','Avacado','Banana');
unset($fruits[1]); // Index 1 which is Mango will be removed from the PHP $fruits array
print_r($fruits);
Continue Reading >>

How to get Client IP Address in PHP

PHP Extract client information from the web server and stored in $_SERVER array. We can get the client IP address from the $_SERVER array by using “REMOTE_ADDR” argument.

$client_ip = $_SERVER["REMOTE_ADDR"];
echo $client_ip;

We can write a simple function which will print the client IP Address.

Continue Reading >>