Sure you can.
Let's say you have an array with 50 elements, something like var array[50]
If you pickup an item, iterate over the array to find free slot and put item there. If there are no free slots, don't pick up the item
Pseudocode:
var inventory[50];
function pickup(picked_item):
for i in range(50):
if inventory[i] == None:
inventory[i] = picked_item.id;