原代码:
$subPageCss1Str.="当前第".$this->current_page."页 / 共".$this->pageNums."页 "; if($this->current_page > 1){ $firstPageUrl=$this->subPage_link."1".$this->wjt_htm; $prewPageUrl=$this->subPage_link.($this->current_page-1).$this->wjt_htm;
$subPageCss1Str.="<a href='$prewPageUrl' \143\x6cass='p\x72\145v\x69\157\x75\163-page'>上一页</a> "; }else {
$subPageCss1Str.="<a \143\x6ca\163\163='\x6e\157-\x70re\166io\165s'>上一页</a> "; } if($this->current_page < $this->pageNums){ $lastPageUrl=$this->subPage_link.$this->pageNums.$this->wjt_htm; $nextPageUrl=$this->subPage_link.($this->current_page+1).$this->wjt_htm; $subPageCss1Str.=" <a href='$nextPageUrl' c\x6c\141\163\x73='\x6e\145\170t-page'>下一页</a> ";
}else { $subPageCss1Str.="<a cla\x73s='\x6e\157-\x6e\x65\x78\x74'>下一页</a> ";
} echo $subPageCss1Str; } function subPageCss2(){ $subPageCss2Str="";
if($this->current_page > 1){ $firstPageUrl=$this->subPage_link."1".$this->wjt_htm; $prewPageUrl=$this->subPage_link.($this->current_page-1).$this->wjt_htm; $subPageCss2Str.="<a href='$firstPageUrl'>首页</a>"; $subPageCss2Str.="<a href='$prewPageUrl' title='转到上一页'>上一页</a>"; }else { $subPageCss2Str.=""; $subPageCss2Str.=""; } $a=$this->construct_num_Page(); for($i=0;$i<count($a);$i++){ $s=$a[$i]; if($s == $this->current_page ){ $subPageCss2Str.="<span>".$s."</span>"; }else{ $url=$this->subPage_link.$s.$this->wjt_htm; $subPageCss2Str.="<a href='$url'>".$s."</a>"; } } if($this->current_page < $this->pageNums){ $lastPageUrl=$this->subPage_link.$this->pageNums.$this->wjt_htm; $nextPageUrl=$this->subPage_link.($this->current_page+1).$this->wjt_htm; $subPageCss2Str.="<a href='$nextPageUrl' title='转到下一页'>下一页</a>"; $subPageCss2Str.="<a href='$lastPageUrl'>尾页</a> "; }else { $subPageCss2Str.=""; $subPageCss2Str.=""; } echo $subPageCss2Str; } } ;
上面的一段中,包含两种8和16,能不能一次性将他们区分开始转换成原代码再组合?
哪位可以帮我写一个函数可以直接转换的,自已调试了半天都没弄出来。只能弄出来单个的。
$data.=chr(hexdec($str));
$data.=chr(octdec($str));
function hex_replace($str){//转换成ASCII
$tmp = substr($str, 0, 1);
if($tmp == 'x' || $tmp == 'X'){ //判断是否是 16 进制, 否则当 8 进制处理
return chr(hexdec($str));
} else {
return chr(octdec($str));
}
}
$str = file_get_contents("cc.txt");
$str = preg_replace('/\\\\([xX][\\dA-Fa-f]{1,2})|\\\\([\\d]{1,3})/e', 'hex_replace(\'$1$2\')', $str);//替换
echo $str;
?>