Location: PHPKode > scripts > Array to List > array-to-list/cuteArray1.php
<?php
/********************************************************************
*  This file contains a class which Makes list from with Arrays		*		
*  Author : Anis uddin Ahamd     									*
*  Mail   : hide@address.com										*
* 
* *******************************************************************	
*    Licence:  GNU General Public License							*
*																	*
*   This program is distributed in the hope that it will be useful,	*	
*   but WITHOUT ANY WARRANTY; without even the implied warranty of	*
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	*
*   GNU General Public License for more details.					*											*
****************************************************************** */

class CuteArray
{
var $core;
    function CuteArray($inputArray)  //constructor
    {
     $this->core=$inputArray;
    }
    
    /*
	Make UnOrdered List of array elements.
    Take optional 4 arguments as 
	1. bool:MainList with Key or not
	2. bool:SubList with Key or not,
	3. mainList_bullet ('square','disc','circle') and 
	4. subList_bullet ('square','disc','circle')
	* */
    function makeUList($withKey=0,$subWithKey=1,$mainBlt='square',$subBlt='disc')
    {
    echo("<UL type=$mainBlt>");
      foreach($this->core as $k=>$v)
      {
       if(is_array($v))
         {
          echo("<li>$k</li>");
          $temp=new CuteArray($v);
          $temp->makeUList($subWithKey,$subWithKey,$subBlt);
         }
        else
        {
        if($withKey)
            echo("<li>$k : <b>$v</b></li>");
        else
            echo("<li>$v</li>");
        }

      }
    echo("</UL>");
    } //end of makeUList()


}

?>

Return current item: Array to List