Trim nbsp from array elements or string

Is there any function in kirby that could help with trimming nbsp from array elements (strings) ?

I usually do with array_map(‘trim’,$array) but that does not seem to remove nbsp.

Thank you

What about like that?

$array = array_map(function($value) { 
    return str_replace(' ', '', $value); 
}, $array);

Perfectly fine.

But as often I find in kirby dedicated tools, such as the V class or the Str class, I figured I could ask if there was something already there for this task.

From your answer, I assume not.

I’ll use a custom function as you suggest, thank you