Location: PHPKode > scripts > Array to List > array-to-list/example.php
<HTML>
<HEAD>
 <TITLE>Working with Arrays</TITLE>
</HEAD>
<BODY>
<?php
 $myChar=array('Name'=>"Anis",
               "occupation" => "Student",
               "age" => 23,
               "special power" => "Java Programming"
               ) ;
 $characters = array(
                 array(
                   "name" => "Bob",
                   "occupation" => "superhero",
                   "age" => 30,
                   "special power" => "x-ray vision"
                  ),
                 array(
                  "name" => "Sally",
                  "occupation" => "superhero",
                  "age" => 24,
                  "special power" => "superhuman strength"
                 ),
                 array(
                  "name" => "Jane",
                  "occupation" => "arch villain",
                  "age" => 45,
                  "special power" => "nanotechnology"
                 )
             );
             
             
//getting outputs and testing types
echo('<b><u>Type of variable $myChar is :</u></b><br>');
print_r($myChar);//prints human readable details of a variable $myChar

echo("<hr color='red' size=3><b><u>So My Details is:</u></b><br>");
foreach($myChar as $k=>$v)
  {
   echo("My $k is :<b>$v</b><br>");
  }

echo("<hr color='blue' size=3><b><u>Type of variable \$characters is :</u></b><br>");
print_r($characters);

//Working including file cuteArray1.php which contains CuteArray class
echo("<hr color='blue' size=3><h2 align='center'><u>Working with Class <font color='red'>cuteArray1</font></u></h2>");

//Includung the class file
include("cuteArray1.php");

echo("<b>Working with Simple 1 dimensional Array<br>With default bullet</b>:");
$Obj1=new CuteArray($myChar);
$Obj1->makeUList();
echo("<b>With argument bullet :</b>");
$Obj1->makeUList(0,0,'circle');
echo("<b>With Choosed bullet and with Key :</b>");
$Obj1->makeUList(1,0,'disc');

echo("<hr color='tomato' size=4><b>Working with  MultiDimensional Array<br>With default bullet</b>:");
$Obj2=new CuteArray($characters);
$Obj2->makeUList();
echo ("<hr color='green' size=3><b>After adding a new assosiated array & Choosed bullet:</b>");
//adding new Array
$characters["I am"]=$myChar;
$Obj3=new CuteArray($characters);
$Obj3->makeUList(0,1,'disc','square');

?>
</BODY>
</HTML>
Return current item: Array to List