<?php
/**
 * Created by PhpStorm.
 * User: marco
 * Date: 16/07/18
 * Time: 19.27
 */
/**
 * @param $model_array
 *
 * @return string
 */
function recursive_list( $model_array ) {
	$title   = $model_array[ o66_model_fields_keys::title ];
	$content = $model_array[ o66_model_fields_keys::content ];
	//$content = $model_array[ o66_model_fields_keys::content ];
	$model_children = $model_array[ o66_model_fields_keys::model_children ];

	function recursive_list_walk($array, &$html = null){

		$html .= "<ul>";
		foreach ($array as $item){
			$fields = get_model_fields($item);
			//var_dump($fields);
			$html .= '<li>';
			$html .= $fields[o66_model_fields_keys::title];
			if (isset($fields[o66_model_fields_keys::model_children])){
				$this_item_children = $fields[o66_model_fields_keys::model_children];
				recursive_list_walk($this_item_children, $html);
			}
			$html .= '</li>';
		}
		$html .= '</ul>';
		return $html;

	}

	$walk_again = false;

	$return_html = recursive_list_walk($model_children);
	return $return_html;




	/*

		if ( isset( $model_array['model_children'] ) ) {
			$this_model_children = $model_array['model_children'];
			foreach ( $this_model_children as $item ) {
			//	prent_r( get_model_fields( $item ) );
			}
		}*/


}