您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

替换结构再判断解决办法

2024/3/17 9:14:23发布27次查看
替换结构再判断
改为:
width和height的值是变动的,如果width 如果width > 805 
那么height = height * 805 /width ; 
  width= 805
这个正则加判断怎么写啊?最近用到好多正则,怎么样才能把正则学好呢?
------解决方案--------------------
请说明你的规则
../documents/medies/esil_xiaoshengqi1.gif
这个乍来的
image:esil_xiaoshengqi1.gif 这个呢?
width=550 height= 400 这个呢???上面有两个,需要哪个?
------解决方案--------------------
参考一下:
php code$s=html;$r= preg_replace('#.+]*>.+#s','',$s);preg_match('#width=(\d+)\s*height=(\d+)#i',$r,$m);if($m[1]>805){ $h=($m[2]*805)/$m[1] ; $r=preg_replace('/(width=)(\d+)(\s*height=)(\d+)/s','$1$2$3'.$h.'',$r);}echo $r;
------解决方案--------------------
php code$s =txt;$r= preg_replace_callback('#.+]*>.+#s', 'back', $s);function back($r) { if($r[3] > 805) { $r[4] = round($r[4]*805/$r[3]); $r[3] = 805; } return txt;}echo $r;

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product