public static function _stringify_data($data)
{
// Booleans are special, lets just makes them and explicit 1/0 instead of the 0 being an empty string.
if (is_bool($data)) {
return $data ? "1" : "0";
}
// Cast objects into arrays.
if (is_object($data)) {
$data = (array) $data;
}
// Non arrays at this point should be just converted to strings.
if (!is_array($data)) {
return (string) $data;
}
foreach ($data as $key => &$value) {
$value = self::_stringify_data($value);
}
return $data;
}