- <?php
- $db = new PDO("mysql:host=localhost;dbname=album", 'root', '');
- $db->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 "<br>";
- }
- ?>
- //该片段来自于http://www.codesnippet.cn/detail/281020136723.html
来源: http://www.codesnippet.cn/detail/281020136723.html