xx 本帖最后由 bxa6965921bxa 于 2014-10-11 21:49:07 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Notice: Undefined variable: 1 in E:\MyPHP\my.php on line 6Warning: preg_replace() [function.preg-replace]: Unknown modifier 'w' in E:\MyPHP\my.php on line 7你想得到什么结果? $string = "April 15, 2003"; $pattern = "/(\w+) (\d+), (\d+)/i"; $replacement = "\${1}1,\$3"; print preg_replace($pattern, $replacement, $string);April1,2003不要盲目的相信网上复制的代码 $string = "April 15, 2003"; $pattern = "/(\w+) (\d+), (\d+)/i"; 这个是正则表达式 (\w+) 表示匹配数字或字母 后面的+表是匹配1个或多个(\d+) 表示匹配多个数字所以用这个正则,能拿到$1 = April$2 = 15$3 = 2003$replacement = "\${1}1,\$3"; 表示把$1和$3替换到$eplacement的位置April1,2003 有做php程序开发的亲友没,我想请教一个php路径问题 求助关于PHP的一个代码问题,很短 第十行变量错误 php上传下载程序的问题,高手帮忙万分感谢 php代码实现 将查询的结果写入excel数据库中 ~循环显示列表信息~ 请问能不能使用javascript?php和javascript结合问题 PHP如何删除文件 怎么自己做的页面打不开? 帮帮小弟我,怎样建设个人网站,很菜很菜的问题. Exec函数 网页挂起问题 配置apache2.4修改documentRoot出现You don't have permission to access / on this server.
Notice: Undefined variable: 1 in E:\MyPHP\my.php on line 6Warning: preg_replace() [function.preg-replace]: Unknown modifier 'w' in E:\MyPHP\my.php on line 7你想得到什么结果?
$pattern = "/(\w+) (\d+), (\d+)/i";
$replacement = "\${1}1,\$3";
print preg_replace($pattern, $replacement, $string);April1,2003不要盲目的相信网上复制的代码
这个是正则表达式
(\w+) 表示匹配数字或字母 后面的+表是匹配1个或多个
(\d+) 表示匹配多个数字
所以用这个正则,能拿到
$1 = April
$2 = 15
$3 = 2003$replacement = "\${1}1,\$3";
表示把$1和$3替换到$eplacement的位置
April1,2003