note 82802 added to function.trim
| From: | luciano | Date: | Sat, 26 Apr 2008 05:17:23 +0000 |
| Subject: | note 82802 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138802@lists.php.net to get a copy of this message | ||
Yet another array trim, recursive too.
I think this one is pretty usefull, though it lacks charlist, you can add that functionality if you
need to, it's not that hard ;)
Anyway, one feature that I added, and I find pretty usefull, is that it can splice an empty position
if you want to
<?php
function array_trim_recursive(&$array, $splice_empty = true) {
foreach($array as $k => &$v) {
if(is_array($v)) {
array_trim_recursive($v, $splice_empty);
} else {
$array[$k] = trim($v);
iif(!$v && $splice_empty) {
array_splice($array, $k, 1);
}
}
}
}
?>
----
Server IP: 190.2.55.3
Probable Submitter: 190.16.198.167
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- https://master.php.net/note/edit/82802
Del: integrated -- https://master.php.net/note/delete/82802/integrated
Del: useless -- https://master.php.net/note/delete/82802/useless
Del: bad code -- https://master.php.net/note/delete/82802/bad+code
Del: spam -- https://master.php.net/note/delete/82802/spam
Del: non-english -- https://master.php.net/note/delete/82802/non-english
Del: in docs -- https://master.php.net/note/delete/82802/in+docs
Del: other reasons-- https://master.php.net/note/delete/82802
Reject -- https://master.php.net/note/reject/82802
Search -- https://master.php.net/manage/user-notes.php