Ejemplo n.º 1
0
function array_without_path($array)
{
    $args = func_get_args();
    array_shift($args);
    foreach ($args as $path) {
        array_path_unset($array, $path);
    }
    return $array;
}
Ejemplo n.º 2
0
/**
 * Generate a query string from an array, optionally replacing and/or removing
 * elements from the array (referenced by path).
 *
 * @param $array array to turn into a query string
 * @param $replace map of paths to replace, and their new values
 * @param $remvoe array of paths to remove
 */
function query_string(array $array, $replace = null, $remove = null)
{
    if ($replace !== null) {
        foreach ((array) $replace as $path => $v) {
            array_path_replace($array, $path, $v);
        }
    }
    if ($remove !== null) {
        foreach ((array) $remove as $path) {
            array_path_unset($array, $path);
        }
    }
    return array_url_encode($array);
}
Ejemplo n.º 3
0
 function test_array_without_path()
 {
     $without = array_without_path($this->foo, 'baz.c');
     array_path_unset($this->foo, 'baz.c');
     assert_equal($without, $this->foo);
 }