PHP头条
热点:

PHP实现C#山寨ArrayList-PHP源码


class ArrayList
{
	public $length;
	public $name;
	public $my_array;
	function __construct()
	{
		$this->my_array=Array();
	}
	public function Add($element)
	{
		array_push($this->my_array, $element);
	}
	
	public function get_Length()
	{
		$this->length=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 "没有这个元素";
		}
	}
	
	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 "没有这个元素";
    	}
    }
    
    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

www.phpzy.comtrue/phpyy/42739.htmlTechArticlePHP实现C#山寨ArrayList-PHP源码 class ArrayList{public $length;public $name;public $my_array;function __construct(){$this->my_array=Array();}public function Add($element){array_push($this->my_array, $element);}public function get_Lengt...

相关文章

PHP之友评论

今天推荐