PHP implementation of C # Cottage ArrayList method,
This paper describes the method of implementing C # Cottage ArrayList in PHP. Share to everyone for your reference. Specific as follows:
Class arraylist{public $length, public $name, public $my _array; function __construct () {$this->my_array=array ();} p ublic function Add ($element) {Array_push ($this->my_array, $element), Public function get_length () {$this->leng Th=count ($this->my_array); return $this->length; Public Function Get_element ($key) {if (Array_key_exists ($key, $this->my_array)) {echo $this->my_array[$key]; } else {echo "does not have this element"; }} Public Function List_array () {foreach ($this->my_array as $value) {echo $value; echo "
"; }} Public Function Delete ($key) {if (Array_key_exists ($key, $this->my_array)) {$this->my_array[$key]=null; } else {echo "does not have this element"; }} Public Function Erase_number () {$pattern = "/[0-9]/"; foreach ($this->my_array as $value) {if (Eregi ($pattern, $value)) {$value =null; }} foreach ($this->my_array as $value) {echo $value; echo "
"; }} Public Function Erase_char () {$pattern = '/a-za-z/'; for ($i =0; $i
My_array)-1, $i + +) {if (Eregi ($pattern, $this->my_array[$i])) {$this->my_array[$i]=null; }} foreach ($this->my_array as $value) {echo $value; echo "
"; } }}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1033492.html www.bkjia.com true http://www.bkjia.com/PHPjc/1033492.html techarticle PHP Implementation of C # Cottage ArrayList method, this article describes the implementation of PHP C # Cottage ArrayList method. Share to everyone for your reference. Specific as follows: Class arraylist{public $length; ....