How do I remove NaN values from an array in php? To remove any other element, I found this solution, but I can’t get it to work for NaN. https://stackoverflow.com/a/7225113/9606753 Context: I am reading data from an rrd Database. I want to calculate the mean across several data entries, however at least one of them is float(NaN). Answer Use array_filter