本文整理匯總了PHP中Arrays::placeInExpanded方法的典型用法代碼示例。如果您正苦於以下問題:PHP Arrays::placeInExpanded方法的具體用法?PHP Arrays::placeInExpanded怎麽用?PHP Arrays::placeInExpanded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Arrays
的用法示例。
在下文中一共展示了Arrays::placeInExpanded方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: placeInExpanded
private static function placeInExpanded($data, array &$nodes, array $expansion_data, $name_property = 'name', $children_property = 'children', $output_type = 'keep_type')
{
$keys = array_keys($expansion_data);
$column = $keys[0];
$data_to_store = array_shift($expansion_data);
$found_node = null;
foreach ($nodes as $node) {
if (Generic::get($node, $name_property) == Generic::get($data, $column)) {
$found_node = $node;
}
}
if ($found_node == null) {
$found_node = array();
$found_node[$name_property] = Generic::get($data, $column);
foreach ($data_to_store as $col) {
$found_node[$col] = Generic::get($data, $col);
}
if (count($expansion_data)) {
$found_node[$children_property] = array();
}
if ($output_type == 'object') {
$found_node = (object) $found_node;
}
$nodes[] = $found_node;
}
if (count($expansion_data)) {
Arrays::placeInExpanded($data, Generic::get($found_node, $children_property), $expansion_data, $name_property, $children_property, $output_type);
}
}