PHP Group Pointer Assignment problem
This post was last edited by Pkkgu on 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;
------Solution--------------------
What's so weird about that?
And it looks pretty clear.
foreach ($ar as $k =?& $v) if (substr ($k,-4) = = ' Path ') $v = $url;
------Solution--------------------
$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);
?>