function _strongarm_readable in Strongarm 6
Same name and namespace in other branches
- 6.2 strongarm.admin.inc \_strongarm_readable()
- 7.2 strongarm.admin.inc \_strongarm_readable()
Display variables in a nicer way.
1 call to _strongarm_readable()
- strongarm_admin_form in ./
strongarm.admin.inc - Variable management strongarm form.
File
- ./
strongarm.admin.inc, line 169
Code
function _strongarm_readable($var) {
if (is_string($var) || is_bool($var) || is_numeric($var)) {
return $var;
}
else {
if (is_array($var)) {
$test = $detected = array();
$test['keys'] = array_keys($var);
$test['values'] = array_values($var);
foreach ($test as $type => $values) {
$numeric = TRUE;
$sequential = 0;
$boolean = TRUE;
foreach ($values as $v) {
$numeric = is_numeric($v) && $numeric;
$sequential = is_numeric($v) && $sequential == $v && $sequential !== FALSE ? $sequential + 1 : FALSE;
$boolean = $boolean && ($v === 0 || $v === 1 || $v === '1' || $v === '0' || $v === TRUE || $v === FALSE);
}
$detected[$type]['numeric'] = $numeric;
$detected[$type]['sequential'] = $sequential !== FALSE;
$detected[$type]['boolean'] = $boolean;
}
// List of things
if (!empty($var) && $detected['keys']['numeric'] && $detected['keys']['sequential']) {
return implode(', ', $var);
}
return '-';
}
}
}