Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


 
 using array to define problem
Author:  (67.71.135.---)
Date:   02-26-04 15:17

Hello everybody:

I'm learning PHP now.
Here are two loop, I don't know what's wrong here.
Please help.

script 1:
for($tempi=1;$tempi<=60; $tempi++){
define('_MI_HIWEEDBLOCKS_BNAME'.$tempi,'group'.$tempi);};
define('_MI_HIWEEDBLOCKS_BNAME61','otherthings');

script 2:
for($tempi=1;$tempi<=60;$tempi++){
$modversion['blocks'][$tempi]['file'] = "latest_of_topic.php";
$modversion['blocks'][$tempi]['name'] = '_MI_HIWEEDBLOCKS_BNAME$tempi';
$modversion['blocks'][$tempi]['description'] = "Shows the last x articles of a topic";
$modversion['blocks'][$tempi]['show_func'] = "latest_of_topic_show";
$modversion['blocks'][$tempi]['edit_func'] = "latest_of_topic_edit";
$modversion['blocks'][$tempi]['options'] = "News|10|1";
}
$modversion['blocks'][61]['file'] = "random_partner.php";
$modversion['blocks'][61]['name'] = _MI_HIWEEDBLOCKS_BNAME61;
$modversion['blocks'][61]['description'] = "Shows a block with 1 random partner banner";
$modversion['blocks'][61]['show_func'] = "random_partners_show";


Thanks a lot.


Best regards

David

 Re: using array to define problem
Author:  (---.cpe.net.cable.roger)
Date:   02-26-04 15:59

define should be outside the loop othewise you overwrite it each time

 Re: using array to define problem
Author:  (67.71.135.---)
Date:   02-26-04 16:12

Thanks Bastien.

So script 1 should change to:
define('_MI_HIWEEDBLOCKS_BNAME1,'group1');
define('_MI_HIWEEDBLOCKS_BNAME2,'group2');
....
define('_MI_HIWEEDBLOCKS_BNAME60,'group60');
define('_MI_HIWEEDBLOCKS_BNAME61','otherthings');


How about script 2 ?
for($tempi=1;$tempi<=60;$tempi++){
$modversion['blocks'][$tempi]['file'] = "latest_of_topic.php";
$modversion['blocks'][$tempi]['name'] = '_MI_HIWEEDBLOCKS_BNAME$tempi';
$modversion['blocks'][$tempi]['description'] = "Shows the last x articles of a topic";
$modversion['blocks'][$tempi]['show_func'] = "latest_of_topic_show";
$modversion['blocks'][$tempi]['edit_func'] = "latest_of_topic_edit";
$modversion['blocks'][$tempi]['options'] = "News|10|1";
}
$modversion['blocks'][61]['file'] = "random_partner.php";
$modversion['blocks'][61]['name'] = _MI_HIWEEDBLOCKS_BNAME61;
$modversion['blocks'][61]['description'] = "Shows a block with 1 random partner banner";
$modversion['blocks'][61]['show_func'] = "random_partners_show";



Best regards

David

 Re: using array to define problem
Author:  (---.l2.c2.dsl.pol.co.uk)
Date:   04-12-04 19:37

here i can help pm me on yahoo bitch_boy_y4h00 or msn [email protected] ok

Go to Top  |  Go to Topic  |  Threaded View  |  Search 
  |  
New Topic
 Reply To This Message
 Your Name:
 Your Email:
 Subject:
Email replies to this thread, to the address above.
  

Provided By
Phorum