What you are making is really strange.
While looping throw your inventory you are building an array from every item in inventory.
You always have a “list of items” with only one item. Why?
Why do you check your inventory for “can pickup”. Inventory items are already pickeduped so no need to check them.
If you really want to get the number count of this “can pickup” items you should plugin inventory array into your filter array function and call it only once before foreach loop or after loop completed.