php - How do I rewrite all variables in $_REQUEST? -


i wondering if there quick way loop through $_request , change submitted variables running them through function.

for example, given $_request['a'] value stuff , $_request['b'] value more stuff. want rewrite entire $_request[] array such value of $_request['a'] became myfunction('stuff') , value of $_request['b'] became myfunction('more stuff'). not know name of of each of elements passed $_request.

you can use array_walk function , pass array. example be:

<?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");  function test_alter(&$item1, $key, $prefix) {     $item1 = "$prefix: $item1"; }  function test_print($item2, $key) {     echo "$key. $item2<br />\n"; }  echo "before ...:\n"; array_walk($fruits, 'test_print');  array_walk($fruits, 'test_alter', 'fruit'); echo "... , after:\n";  array_walk($fruits, 'test_print'); ?> 

the same way, problem, can this:

function stuff() {    /// } 

and walk $_request through function way:

array_walk($_request, 'stuff', 'fruit'); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -