<?php
/**
* 我想把字符串中含有 http://blog.3snews.net/?uid-41069-action-viewspace-itemid-27559 替换成
* http://blog.3snews.net/index.php?uid=41069&itemid=27559 (保留原来的参数替换链接)
*
**/
$str1 = "左字符串http://blog.3snews.net/?uid-41069-action-viewspace-itemid-27559右字符串";
$str2 = "左字符串http://blog.3snews.net/?uid-5551-action-viewspace-itemid-12345右字符串";?>
字符串规则:http://blog.3snews.net/?uid-任意UID-action-viewspace-itemid-任意ITEMID
替换规则 :http://blog.3snews.net/index.php?uid=对应上面的UID&itemid=对应上面的ITEMID
把$str1、$str2这一类字符串中的链接按规则替换
/**
* 我想把字符串中含有 http://blog.3snews.net/?uid-41069-action-viewspace-itemid-27559 替换成
* http://blog.3snews.net/index.php?uid=41069&itemid=27559 (保留原来的参数替换链接)
*
**/
$str1 = "左字符串http://blog.3snews.net/?uid-41069-action-viewspace-itemid-27559右字符串";
$str2 = "左字符串http://blog.3snews.net/?uid-5551-action-viewspace-itemid-12345右字符串";?>
字符串规则:http://blog.3snews.net/?uid-任意UID-action-viewspace-itemid-任意ITEMID
替换规则 :http://blog.3snews.net/index.php?uid=对应上面的UID&itemid=对应上面的ITEMID
把$str1、$str2这一类字符串中的链接按规则替换
解决方案 »
- 关于安装jpgraph的问题,望各位解答一下
- 请教个rewrite规则 apache 的
- 求解:php配置问题
- PHP菜鸟问题,初学者,大家多帮忙!
- 请问: 在PHP5中,需要上传一个文件从用户端到服务器端。如何实现?
- php不能与mysql数据库连接,请求高手帮忙!
- 大家看看做这样一个网站系统应收多少钱???
- 新闻浏览实现点击上一条,下一条,搜索mysql数据
- 我不得不说自己是名副其实的笨笨
- 中文 用javascript的escape()编码后,php怎么还原??
- include老是出问题
- mysql_real_escape_string过滤字符要求数据库连接,是意味着使用它过滤字符将影响效率?
$str = '左字符串http://blog.3snews.net/?uid-41069-action-viewspace-itemid-27559右字符串左字符串http://blog.3snews.net/?uid-5551-action-viewspace-itemid-12345右字符串';echo preg_replace('/http:\/\/blog\.3snews\.net\/\?uid\-(\d+)-action-viewspace-itemid-(\d+)/is', 'http://blog.3snews.net/index.php?uid=$1&itemid=$2', $str);