Compare values ​between two arrays [closed]

I called the values ​​from the database by the following commands:

<?php
$server = "localhost";
$user = "root";
$pass = "root";
$database = "elahieh33"; 
$con = mysqli_connect($server, $user, $pass);
$con->set_charset("utf8");
if(!$con){
    echo 'Server not connected';
}
$db = mysqli_select_db($con, $database);
if(!$db){
    echo 'Database not connected';
}

$result = $con->query("SELECT id FROM `wp_posts` WHERE post_type = 'shop_order' ");
$result1 = $con->query("SELECT post_id FROM `wp_postmeta` WHERE meta_key = '_billing_first_name' ");


$r = array();
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {

        $r[] = $row;        
    }     
}

$r1 = array();
if ($result1->num_rows > 0) {
    while ($row1 = $result1->fetch_assoc()) {

        $r1[] = $row1;  
    }     
}

Now I want to compare the values ​​of two arrays and show the common values, I use the following command to compare the values, but I don’t get the correct answer:

$result2 = array_intersect($r, $r1);
print_r($result2);

Error message after executing the last command: “Notice: Array to string conversion”

please guide me.