- filter_var: documentation ( source)
- var_export: documentation ( source)
<?php
$body = [
'key2' => ' abc ',
'key3' => false,
'key4' => true,
'key5' => null,
];
$body = filter_var($body, FILTER_CALLBACK, ['options' => 'trim']);
var_export($body);