We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Docs

Item callback function (using 'each')

Hi,

could I double-check something with you?

Quoting the docs, in relation to using

'each' => function($item) {...

"After processing, the function must return the array."

I've been playing with this and returning nothing from the function works absolutely fine - is this by design? If so, I can use 'each' to provide some extra-fine filtering, so some items are returned, others aren't. Just thought I'd check with you before committing with my code - I don't want it to break in a future version... ;-)

This is using 2.8.31.

Duncan Revell

Duncan Revell 78 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The idea is you get handed $item, you manipulate it, and then you return it.

If you don't return $item then that item won't be included in the result.

Duncan Revell

Duncan Revell 78 points
Registered Developer

Thanks Drew - I know that's the idea, it's just that in a current case, I can use this to provide 'extra' filtering by not returning $item.

Cheers.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Right, as I said, that's how it works.