欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP组指针赋值问题

程序员文章站 2022-05-20 12:28:07
...
$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;


回复讨论(解决方案)

楼主的问题是?

$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;


这种赋值方法好像有点怪怪的

楼主的问题是?



这种赋值方法好像有点怪怪的

$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;

这有什么“怪”呢?
看上去也还算清晰明了

foreach($ar as $k=?&$v) if(substr($k, -4) == 'Path') $v = $url;

请教
$k= ?&$v ??

$k=>&$v
不好意思,按错了键

$k=>&$v
不好意思,按错了键


地址引用,我咋没想到!!!!! 好办法啊!

不引用也是一样的

foreach($ar as $k=>$v) if(substr($k, -4) == 'Path') $ar[$k] = $url;

$val){    if(substr($key,0,5)=='image'){        $arr[$key] = $url;    }}print_r($arr);?>
相关标签: 赋值 php 指针