How to Get Common Values from Two Array in PHP?

Hello friends, today I will tell you through my tutorial how you can get the command value from 2 array through php. Today I will tell you step to step explain through this tutorial.

fetch comman values from two array using php, from 2 array extract specific value by php, get specific value in two array by php 

in_array function :- Using this function we can find out if specific values ​​are available in an array or not. If the specified value is available on any element of the array, it returns the function of php true. Otherwise it returns false.

<?php 
$array_1 = array("8","20","25","30","40");
$array_2 = array("15","25","38","40","45");
$final_array = array();
foreach($array_1 as $key=>$val){
if(in_array($val,$array_2)){
echo $final_array[] = $val."<br>";
}
}
print_r($final_array);
?>