对于循环问题? [英] For loop question?

查看:89
本文介绍了对于循环问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有几个代表不同类别的数组。每个类别一个

数组。数组包含照片的名称。阵列

看起来像这样:


$ cat_1 = array(''moonlight.jpg'''',shadow.jpg'',''luna .jpg'');

$ cat_2 =数组(...);

$ cat_3 =数组(...);

$ cat_4 = array(...);


然后,我想创建一个包含所有照片的缩略图:

for($ i = 0; ...){

....< img src =" images / thumbs /<?php echo $ cat_1 [$ i]; ?>" />

}


这适用于第一个数组。

如果我得到的名称怎么办?变量中的数组?我怎么用
构建我的''for loop''。


我这样做:


$ cat = $ _GET [''cat'']; //输出:1

$ sel_array =''cat_''。 $ cat; //创建字符串:cat_1


然后我创建这样的大拇指:

for($ i = 0; ...){

....< img src =" images / thumbs /<?php echo HELP !!!! ;?>" />

}

如何构建缩略图?

谢谢

Marco

解决方案

cat_1 = array(''moonlight.jpg'''',shadow.jpg'',''luna.jpg'');


cat_2 = array(...);


cat_3 = array(...);



I have a couple of arrays that represent different categories. One
array per category. The arrays contain names of photos. The arrays
look like this:

$cat_1 = array(''moonlight.jpg'''', shadow.jpg'', ''luna.jpg'');
$cat_2 = array(...);
$cat_3 = array(...);
$cat_4 = array(...);

Then, i want to create a thumbnail with all the photos like this:
for($i=0; ...){
....<img src="images/thumbs/<?php echo $cat_1[$i]; ?>" />
}

This works OK for the first array.
What if i''m getting the name of the array from a variable? How do i
construct my ''for loop''.

I do it like this:

$cat = $_GET[''cat'']; //output: 1
$sel_array = ''cat_'' . $cat;//create the string: cat_1

Then i create the thumbs like this:
for($i=0; ...){
....<img src="images/thumbs/<?php echo HELP!!!! ;?>" />
}
How do i construct the thumbnail?
Thanks
Marco

解决方案

cat_1 = array(''moonlight.jpg'''', shadow.jpg'', ''luna.jpg'');


cat_2 = array(...);


cat_3 = array(...);


这篇关于对于循环问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆