PHP implementation of C # Cottage ArrayList method, _php tutorial

Source: Internet
Author: User

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; ....

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.