Rav Tzvi Hirsch of Ziditchoiv zy”a (quoted in Divrei Shaul) and Rav Meir of Premishlan zy”a (quoted in Divrei Meir), both explain this pasuk as follows:
Chazal say that Yosef acquired all of the money in Mitzrayim. The coins in Egypt had images of idols on them, so how was Yosef permitted to take their idols when we know that it is forbidden to derive any benefit from such things?
The pasuk answers this question when it says that they gave idols ‘b’shever’. This word indicates ‘shevirah’, breaking. The halacha is (Avodah Zara 42A) that a non-Jew can break his own idol and thereby remove its status as a forbidden object. Thus, Yosef commanded the gentiles to break the coins before they gave them to Yosef. Therefore, it was permitted for him to take them.
וַיְלַקֵּט יוֹסֵף אֶת כָּל הַכֶּסֶף וגו' בַּשֶּׁבֶר אֲשֶׁר הֵם שֹׁבְרִ ים וַיָּבֵא יוֹסֵף אֶת הַכֶּסֶף בֵּיתָה פַרְ עֹה (מז, יד)
And Yosef collected all the money...with the grain that they were buying, and Yosef brought the money into Pharaoh’s house. (47:14)
