note 120269 deleted from function.trim by cmb
| From: | cmb@php.net | Date: | Sat, 03 Dec 2016 22:40:44 +0000 |
| Subject: | note 120269 deleted from function.trim by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207971@lists.php.net to get a copy of this message | ||
Note Submitter: axew3 at axew3 dot com
----
To trim() each value of an $_POSTS array, i've try custom not working filters and others
examples like the default above trim() example with array_walk (that maybe i'm wrong, but on my
tests it reset array values, like another with array filter, that work only on php 5.6, but not in 7
(and i had to add return in these cases for my tests inside methods))
but inside a class, a call like:
array_walk($fruit, 'self::trim_value');
where the trim_value is the above example function,
was not working for me, at best, working on php 5.6, and not in 7, where values were passed same as
before, or empty.
So i've do this to trim() each $_POST array value, within the function:
$k = array_keys($_POST['conf']);
$v = array_values($_POST['conf']);
foreach($v as $vv):
$vvv[] = trim($vv);
endforeach;
$v = array_values($vvv);
$postconf = array_combine ($k ,$v);
// $postconf look like $_POST['conf'] now, but with all values of $_POST['conf']
trimmed on 5.6 and 7