20220406
This commit is contained in:
86
vendor/chinadoi/include/ArrayList.class.php
vendored
Normal file
86
vendor/chinadoi/include/ArrayList.class.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*
|
||||
* @author:administrator
|
||||
* @createTime:2016-07-03
|
||||
*/
|
||||
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($key)
|
||||
{
|
||||
if(array_key_exists($key, $this->my_array))
|
||||
{
|
||||
echo $this->my_array[$key];
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>";
|
||||
}
|
||||
}
|
||||
public function list_array()
|
||||
{
|
||||
foreach ($this->my_array as $value)
|
||||
{
|
||||
echo $value;
|
||||
echo "<br/>";
|
||||
}
|
||||
}
|
||||
public function Delete($key)
|
||||
{
|
||||
if(array_key_exists($key, $this->my_array))
|
||||
{
|
||||
$this->my_array[$key]=null;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>";
|
||||
}
|
||||
}
|
||||
public function erase_number()
|
||||
{
|
||||
$pattern="/[0-9]/";
|
||||
foreach ($this->my_array as $value)
|
||||
{
|
||||
if(eregi($pattern, $value))
|
||||
{
|
||||
$value="";
|
||||
}
|
||||
}
|
||||
foreach ($this->my_array as $value)
|
||||
{
|
||||
echo $value;
|
||||
echo"<br/>";
|
||||
}
|
||||
}
|
||||
public function erase_char()
|
||||
{
|
||||
$pattern='/a-zA-Z/';
|
||||
for($i=0;$i<count($this->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 "<br/>";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user