php正则表达式 匹配问题 急 本帖最后由 fudg1211 于 2010-02-23 13:45:43 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接替换函数就行啊str_replace <?$a='<input type="text" name="user"><input type="text" name="password">';$a='<input type="text" name="user" value="$user"><input type="text" name="password" value="$password">';?>属性name的值是value的值变量 要多理解下 $a='<input type="text" name="user"><input type="text" name="password">';$a = preg_replace('/(\<input.+name=)([\'\"])(.+)[\'\"](.*\>)/Uis', "$1$2$3$2 value=\"\$$3\"$4", $a);echo $a; 需要两个正则 先匹配出name的值 a 在替换了 name="a" 为 name="a" value="a" $a = '<input type="text" name="user"><input type="text" name="password">';$a = preg_replace('/ name="(\w+)"/',' name="\1" value="$\1"',$a);var_dump($a); $a = preg_replace('/(\<input.+name=)([\'\"])(.+)[\'\"](.*\>)/Uis', "$1$2$3$2 value=\"\$$3\"$4", $a);请问大侠 $1$2$3$2该怎么理解啊 头大了 $a = '<input type="text" name="user"><input type="text" name="password">';echo preg_replace('/(<input.+?name=[\'"]?)([^\'" >]+)([\'"]?.*?)>/i', '$1$2$3 value=\'\$$2\'>', $a); register_shutdown_function无效,大家帮忙看看 MYSQL语句问题? 如何做php程序安装? php+mysql网站,如何将数据导出到EXCEL文件 用软件修改php.ini的方法 网页嵌入播放器播放wmv的问题,关于进度拖放 关于手机访问的页面中,select显示错误的问题 phpwind 论坛安装异常 这个是怎么回事?请大家帮忙 php 的基础问题! PHP上传文件限制大小的问题 为什么页面上显示HTML源代码?
$a='<input type="text" name="user"><input type="text" name="password">';$a = preg_replace('/(\<input.+name=)([\'\"])(.+)[\'\"](.*\>)/Uis', "$1$2$3$2 value=\"\$$3\"$4", $a);echo $a;
在替换了 name="a" 为 name="a" value="a"
$a = preg_replace('/ name="(\w+)"/',' name="\1" value="$\1"',$a);
var_dump($a);
请问大侠 $1$2$3$2该怎么理解啊 头大了
echo preg_replace('/(<input.+?name=[\'"]?)([^\'" >]+)([\'"]?.*?)>/i', '$1$2$3 value=\'\$$2\'>', $a);