<?php
$ids = [1,2,3,4,5];
$stmt = $mysqli->prepare("SELECT * FROM somewhere WHERE id IN (" . rtrim(str_repeat('?,', count($ids)), ',') . ") ORDER BY id");
$sql = "SELECT * FROM somewhere WHERE id IN (" . rtrim(str_repeat('?,', count($ids)), ',') . ") ORDER BY id";
echo $sql;
$stmt->execute($ids);
$result = $stmt->get_result();
var_export($result->fetch_all(MYSQLI_ASSOC));