打包好的字符串操作函数
<?php
class get_c_str {
var $str;
var $start_str;
var $end_str;
var $start_pos;
var $end_pos;
var $c_str_l;
var $contents;
//查找2个字符串之间的字符串。
function get_str($str,$start_str,$end_str){
$this->str = $str;
$this->start_str = $start_str;
$this->end_str = $end_str;
$this->start_pos = strpos($this->str,$this->start_str)+strlen($this->start_str);
$this->end_pos = strpos($this->str,$this->end_str);
$this->c_str_l = $this->end_pos - $this->start_pos;
$this->contents = substr($this->str,$this->start_pos,$this->c_str_l);
return $this->contents;
}
//查找字符串之后的所有字符串。
function get_behind_str($str,$start_str){
$start=$start_str;
$oristr=$str;
$str_start=strpos($oristr,$start)+strlen($start);
$result_str=substr($oristr,$str_start,strlen($oristr));
return $result_str;
}
}所有代码都已测试过,可直接使用。
class get_c_str {
var $str;
var $start_str;
var $end_str;
var $start_pos;
var $end_pos;
var $c_str_l;
var $contents;
//查找2个字符串之间的字符串。
function get_str($str,$start_str,$end_str){
$this->str = $str;
$this->start_str = $start_str;
$this->end_str = $end_str;
$this->start_pos = strpos($this->str,$this->start_str)+strlen($this->start_str);
$this->end_pos = strpos($this->str,$this->end_str);
$this->c_str_l = $this->end_pos - $this->start_pos;
$this->contents = substr($this->str,$this->start_pos,$this->c_str_l);
return $this->contents;
}
//查找字符串之后的所有字符串。
function get_behind_str($str,$start_str){
$start=$start_str;
$oristr=$str;
$str_start=strpos($oristr,$start)+strlen($start);
$result_str=substr($oristr,$str_start,strlen($oristr));
return $result_str;
}
}所有代码都已测试过,可直接使用。