PHP运用正则表达式获取字符串中的特定字符-PHP源码
1. [PHP]代码
query("set names gb2312"); $sql="SELECT * FROM `sales"`; $rows = $db->query($sql)->fetchall(); foreach($rows as $row) { $str = $row['detail']; preg_match("/[".chr(0xa1)."-".chr(0xff)."]{4}市/",$str,$regs); echo $regs[0]?$regs[0]:'暂无'; echo "
"; } ?>
PHP之友评论