function tripal_bulk_loader_flatten_array
2.x tripal_bulk_loader.loader.inc | tripal_bulk_loader_flatten_array($values) |
3.x tripal_bulk_loader.loader.inc | tripal_bulk_loader_flatten_array($values) |
1.x tripal_bulk_loader.loader.inc | tripal_bulk_loader_flatten_array($values) |
Flattens an array up to two levels Used for printing of arrays without taking up much space
Related topics
File
- tripal_bulk_loader/
includes/ tripal_bulk_loader.loader.inc, line 1057 - Handles the actual loading of data.
Code
function tripal_bulk_loader_flatten_array($values) {
$flattened_values = array();
foreach ($values as $k => $v) {
if (is_array($v)) {
$vstr = array();
foreach ($v as $vk => $vv) {
if (drupal_strlen($vv) > 20) {
$vstr[] = $vk . '=>' . drupal_substr($vv, 0, 20) . '...';
}
else {
$vstr[] = $vk . '=>' . $vv;
}
}
$v = '{' . implode(',', $vstr) . '}';
}
elseif (drupal_strlen($v) > 20) {
$v = drupal_substr($v, 0, 20) . '...';
}
$flattened_values[] = $k . '=>' . $v;
}
return implode(', ', $flattened_values);
}