本文整理汇总了PHP中sfToolkit::getArrayValueForPathByRef方法的典型用法代码示例。如果您正苦于以下问题:PHP sfToolkit::getArrayValueForPathByRef方法的具体用法?PHP sfToolkit::getArrayValueForPathByRef怎么用?PHP sfToolkit::getArrayValueForPathByRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfToolkit
的用法示例。
在下文中一共展示了sfToolkit::getArrayValueForPathByRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValue
protected function getValue(&$values, $name, $shiftArray = false)
{
if (array_key_exists($name, $values)) {
$return =& $values[$name];
} else {
$return =& sfToolkit::getArrayValueForPathByRef($values, $name);
}
if ($shiftArray && is_array($return)) {
// we need to remove the first element from the array. Therefore we need a reference
return array_shift($return);
}
return $return;
}
示例2: array
$t->is(sfToolkit::getArrayValueForPath($arr, 'foo[bar][baz]'), 'foo bar', '::getArrayValueForPath() works with deep paths');
$t->is(sfToolkit::getArrayValueForPath($arr, 'foo[bar][bar]'), false, '::getArrayValueForPath() works with deep paths');
$t->is(sfToolkit::getArrayValueForPath($arr, 'foo[bar][bar]', 'bar'), 'bar', '::getArrayValueForPath() works with deep paths');
$t->is(sfToolkit::getArrayValueForPath($arr, 'foo[]'), array('bar' => array('baz' => 'foo bar')), '::getArrayValueForPath() accepts a [] at the end to check for an array');
$t->is(sfToolkit::getArrayValueForPath($arr, 'foobar[]'), null, '::getArrayValueForPath() accepts a [] at the end to check for an array');
$t->is(sfToolkit::getArrayValueForPath($arr, 'barfoo[]'), null, '::getArrayValueForPath() accepts a [] at the end to check for an array');
$t->is(sfToolkit::getArrayValueForPath($arr, 'foobar[]', 'foo'), 'foo', '::getArrayValueForPath() accepts a [] at the end to check for an array');
$t->is(sfToolkit::getArrayValueForPath($arr, 'bar[1]'), 'bar', '::getArrayValueForPath() can take an array indexed by integer');
$t->is(sfToolkit::getArrayValueForPath($arr, 'bar[2]'), null, '::getArrayValueForPath() can take an array indexed by integer');
$t->is(sfToolkit::getArrayValueForPath($arr, 'bar[2]', 'foo'), 'foo', '::getArrayValueForPath() can take an array indexed by integer');
$t->is(sfToolkit::getArrayValueForPath($arr, 'foo[bar][baz][booze]'), null, '::getArrayValueForPath() is not fooled by php mistaking strings and array');
$t->is(sfToolkit::getArrayValueForPathByRef($arr, 'foo[bar][baz][booze]'), null, '::getArrayValueForPathByRef() is not fooled by php mistaking strings and array');
// ::removeArrayValueForPath()
$t->diag('::removeArrayValueForPath()');
$t->is(sfToolkit::removeArrayValueForPath($arr, 'foobar'), 'foo', '::removeArrayValueForPath() returns the removed value');
$t->is($arr, array(
'foo' => array(
'bar' => array(
'baz' => 'foo bar',
),
),
'bar' => array(
'foo',
'bar',
),
'simple' => 'string',