...
PHP组指针赋值问题
本帖最后由 pkkgu 于 2014-05-30 09:18:25 编辑
$arr=array();
$arr['imagePath']="";
$arr['Size1']="";
$arr['imageaPath']="";
$arr['image2Path']="";
$arr['Size33']="";
$arr['image5Path']="";
$arr['Size55']="";
$arr['imagebbPath']="";
$arr['imageccPath']="";
$arr['Size555']="";
$arr['imageqqPath']="";
$arr['image99Path']="";
$arr['imageeePath']="";
$arr['imagepPath']="";
$arr['Size66']="";
$url='/';
$arr['imagePath']=$url;
$arr['imageaPath']=$url;
$arr['image2Path']=$url;
$arr['image5Path']=$url;
$arr['imagebbPath']=$url;
$arr['imageccPath']=$url;
$arr['imageqqPath']=$url;
$arr['image99Path']=$url;
$arr['imageeePath']=$url;
$arr['imagepPath']=$url;
------解决方案--------------------这有什么“怪”呢?
看上去也还算清晰明了
foreach($ar as $k=?&$v) if(substr($k, -4) == 'Path') $v = $url;
------解决方案--------------------
$arr=array();
$arr['imagePath']="";
$arr['Size1']="";
$arr['imageaPath']="";
$arr['image2Path']="";
$arr['Size33']="";
$arr['image5Path']="";
$arr['Size55']="";
$arr['imagebbPath']="";
$arr['imageccPath']="";
$arr['Size555']="";
$arr['imageqqPath']="";
$arr['image99Path']="";
$arr['imageeePath']="";
$arr['imagepPath']="";
$arr['Size66']="";
$url = '/';
foreach($arr as $key=>$val){
if(substr($key,0,5)=='image'){
$arr[$key] = $url;
}
}
print_r($arr);
?>
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
相关文章
相关视频
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论