I have a array call newArray();
$values = array_count_values($books);
arsort($values);
$newArray = array_keys($values);
it have data like below
Array ( [0] => 37 [1] => 31 [2] => 29 [3] => 28 [4] => 20 [5] => 26 [6] => 34 [7] => 30 [8] => 25 )
how can i get first 5 index in that array and how to write query for those remain values
as example
[0]=>37 from this
get books from books table that id equals to 37 something like that
please help me with this anything will be helpful
EDIT
array have values like this
Array ( [0] => 37 [1] => 31 [2] => 29 [3] => 28 [4] => 20 [5] => 26 [6] => 34 [7] => 30 [8] => 25 )
function like below
if(!empty($books)) {
$values = array_count_values($books);
arsort($values);
$newArray = array_keys($values);
$views_books_array = array_slice($newArray, 0, 5);
$result = $this->db->where_in('book_id',$views_books_array)->get('books');
print_r($result);
return $result->result_array();
}
$result not getting what i need what did i do wrong?