public static function convertByParent($data, $parent_field, $options = []) {
		$pointers = [];
		foreach ($data as $k => $v) {
			if (empty($v[$parent_field])) {
				continue;
			}
			// if parent is down the road
			if (!empty($data[$v[$parent_field]])) {
				$data[$v[$parent_field]]['options'][$k] = $data[$k];
				// disable parents
				if (!empty($options['disable_parents'])) {
					$data[$v[$parent_field]]['disabled'] = 1;
				}
				$pointers[$k] = & $data[$v[$parent_field]]['options'][$k];
				unset($data[$k]);
			} else if (!empty($pointers[$v[$parent_field]])) {
				$pointer = & $pointers[$v[$parent_field]];
				$pointer['options'][$k] = $data[$k];
				$pointers[$k] = & $pointer['options'][$k];
				unset($data[$k]);
			}
		}
		return $data;
	}
public static function convertByParent($data, $parent_field, $options = []) {
		$pointers = [];
		foreach ($data as $k => $v) {
			if (empty($v[$parent_field])) {
				continue;
			}
			// if parent is down the road
			if (!empty($data[$v[$parent_field]])) {
				$data[$v[$parent_field]]['options'][$k] = $data[$k];
				// disable parents
				if (!empty($options['disable_parents'])) {
					$data[$v[$parent_field]]['disabled'] = 1;
				}
				$pointers[$k] = & $data[$v[$parent_field]]['options'][$k];
				unset($data[$k]);
			} else if (!empty($pointers[$v[$parent_field]])) {
				$pointer = & $pointers[$v[$parent_field]];
				$pointer['options'][$k] = $data[$k];
				$pointers[$k] = & $pointer['options'][$k];
				unset($data[$k]);
			}
		}
		return $data;
	}
public static function convertByParent ( $ data , $ parent_field , $ options = [ ] ) { $ pointers = [ ] ; foreach ( $ data as $ k => $ v ) { if ( empty ( $ v [ $ parent_field ] ) ) { continue ; } // if parent is down the road if ( ! empty ( $ data [ $ v [ $ parent_field ] ] ) ) { $ data [ $ v [ $ parent_field ] ] [ 'options' ] [ $ k ] = $ data [ $ k ] ; // disable parents if ( ! empty ( $ options [ 'disable_parents' ] ) ) { $ data [ $ v [ $ parent_field ] ] [ 'disabled' ] = 1 ; } $ pointers [ $ k ] = & $ data [ $ v [ $ parent_field ] ] [ 'options' ] [ $ k ] ; unset ( $ data [ $ k ] ) ; } else if ( ! empty ( $ pointers [ $ v [ $ parent_field ] ] ) ) { $ pointer = & $ pointers [ $ v [ $ parent_field ] ] ; $ pointer [ 'options' ] [ $ k ] = $ data [ $ k ] ; $ pointers [ $ k ] = & $ pointer [ 'options' ] [ $ k ] ; unset ( $ data [ $ k ] ) ; } } return $ data ; }
Convert array to a tree using parent field

@param array $data
@param string $parent_field
@param array $options
boolean disable_parents
Convert array to a tree using parent field