I have tried implementing the basic features of ArrayList (Java ) in PHP .The Arraylist should be capable of adding any type of object (generic as in Java) Can anyone give suggestion for improvement in design/implementation. Here is the code
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class ArrayList
{
private $arrVar;
function __construct($option)
{
$this->arrVar = array();
array_push($this->arrVar,$option);
}
function addValue($option)
{
array_push($this->arrVar,$option);
}
function getLastValue()
{
$arr = array_pop($this->arrVar);
return $arr;
}
}
?>
iterator. See here for an example of using them with an array of objects.