本文整理匯總了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',