/e/tags/index.php?page=23&tagname=%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4&line=3&tempid=13
用preg_replace()把这样的替换成
/tag-%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4/23/
当page=0的时候替换成
/tag-%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4/
$str="/e/tags/index.php?page=0&tagname=%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4&line=3&tempid=13";$s= preg_replace_callback( '#.+?page=(\d+)&tagname=([^&]+)&.+#', create_function( '$matches', 'return "/tag-$matches[2]/". ($matches[1] ? $matches[1]."/" : "");' ), $str);echo $s;
$str="/e/tags/index.php?page=0&tagname=%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4&line=3&tempid=13";$s= preg_replace_callback( '#.+?page=(\d+)&tagname=([^&]+)&.+#', create_function( '$matches', 'return "/tag-$matches[2]/". ($matches[1] ? $matches[1]."/" : "");' ), $str);echo $s;
$str="/e/tags/index.php?page=0&tagname=%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4&line=3&tempid=13";$s= preg_replace_callback( '#.+?page=(\d+)&tagname=([^&]+)&.+#', create_function( '$matches', 'return "/tag-$matches[2]/". ($matches[1] ? $matches[1]."/" : "");' ), $str);echo $s;
<a title="总数"> <b>5</b> </a> <a href="/e/tags/index.php?page=0&tagname=关于友谊珍贵的格言&line=3&tempid=13">首页</a> <a href="/e/tags/index.php?page=0&tagname=关于友谊珍贵的格言&line=3&tempid=13">上一页</a> <a href="/e/tags/index.php?page=0&tagname=关于友谊珍贵的格言&line=3&tempid=13">1</a> <b>2</b>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号