Filling a mesh guide with stacked array

I’ve been racking my brain lately trying to figure out how to simply fill a mesh “guide” object with a stacked array of smaller objects. I want to eliminate those parts of the array that don’t fit inside the guide mesh. I’ve tried generating an array of cubes with nested array modifiers, for example, and then using Boolean tools and Boolean modifiers to get the intersection but this leaves me with “partial” cubes. What is the best way to achieve this effect?