How to use php array with sql IN operator?

You can use the implode() function to convert the PHP array into a string of comma-separated values, and then use that string in the SQL query with the IN operator. Here is an example:

<?php

$arr = [1, 2, 3, 4];
$in = implode(',', $arr);
$sql = "SELECT * FROM table WHERE column IN ($in)";

Watch a course Learn object oriented PHP

You can use $sql to execute in your query.

<?php

$result = mysqli_query($conn, $sql);

Also make sure to properly sanitize the input array before using it in the query to prevent SQL injection.