vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Does PHP 5.x allow nested loops? (https://vborg.vbsupport.ru/showthread.php?t=92042)

Michael Morris 07-12-2005 02:19 PM

Does PHP 5.x allow nested loops?
 
Cause 4 sure as hell don't and it's annoying the crap out of me. I've found you can next a foreach in a while, and then nest that in a for loop, but beyond that you're SOL. I'm writing a vote counting program and I need to have a four layer deep nested loop.

I'm so fustrated with it I'm about ready to write a visual basic program to do the job (I know how to set up the MyOBDC driver to do it).

The Geek 07-12-2005 03:10 PM

I may be barking up a tree - however as far as I know you can nest all you want. FOr instance, this is perfectly valid and works:
PHP Code:

foreach($array1 as $key1=>$value1){
foreach(
$value1 as $key2=>$value2){
foreach(
$value2 as $key3=>$value3){
foreach(
$value3 as $key4=>$value4){
echo(
"er... shall I go on?");
 
}
}



glad to see the indent feature works in php blocks ;)

Marco van Herwaarden 07-12-2005 03:23 PM

Could you post some code samples, because it is for sure possible to create nested loops.

Michael Morris 07-12-2005 04:05 PM

Nevermind, I strategically placed some echo statements to throw back the counters to the screen in the loops - it is looping, something else is wrong :(


All times are GMT. The time now is 01:30 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00897 seconds
  • Memory Usage 1,703KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete