Getting 50 records from array php

Viewed 170

I have a json file which I am converting it to array and then trying to get 50 elements from the array.

But for some reason my code is not working and it is throwing 212 elements instead of 50

Please see my code below:

$json_file = file_get_contents("/directory/jsonfile.json");
$json_data = json_decode($json_file, true);
$json_data = array_slice((array)$json_data, 0, 50);
print_r (array_count_values($json_data)); // this still showing 212 results
1 Answers
Related