/ Published in: PHP

The first argument is a variable name which value should be extracted from $array (second argument), or array of keys (multidim array is also supported).
The third argument is a default value which will be return on fail (false by default).
Usage examples:
1) $value = array_traverse('user[name]', $_POST);
2) $value = array_traverse(array('user' => array('name' => '')), $_POST);
The third argument is a default value which will be return on fail (false by default).
Usage examples:
1) $value = array_traverse('user[name]', $_POST);
2) $value = array_traverse(array('user' => array('name' => '')), $_POST);
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function array_traverse($name, $array, $default = false) { $ref =& $array; $ref =& $ref[$first_key]; $v = $v[$first_key]; } else return $default; } return $ref; } return $default; }
Comments
