Web Analytics Made Easy -
StatCounter Multi Array problem(s) - CodingForum

Announcement

Collapse
No announcement yet.

Multi Array problem(s)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multi Array problem(s)

    I'm working on a todo-site, for myself and maybe to publish.

    I'm trying to use Multi-Arrays, but the code below could (should) be shorter, I'm quite sure about that.

    Here's the code:
    Code:
    	foreach $todo (@todos) {
    		(@the_todos->[$n][0],@the_todos->[$n][1],@the_todos->[$n][2],@the_todos->[$n][3],@the_todos->[$n][4]) = split(/\|/,$todo);
    		@test = split(/\|/,$todo);
    		$n++;
    	}
    	@the_todos = sort date(@the_todos);
    	@the_todos = sort priority(@the_todos);
    	$n=0;
    	foreach (@the_todos) {
    		#print "@the_todos->[$n][0] @the_todos->[$n][1] @the_todos->[$n][2] @the_todos->[$n][3] @the_todos->[$n][4]<BR>";
    		&print_todo(@the_todos->[$n][0],@the_todos->[$n][1],@the_todos->[$n][2],@the_todos->[$n][3],@the_todos->[$n][4]);
    		$n++;
    	}
    @todos contains the info from the file like this:
    1|To Do #1|1|1|95849384
    The part that should be shorter is the
    @the_todos->[$n][0],@the_todos->[$n][1],@the_todos->[$n][2],@the_todos->[$n][3],@the_todos->[$n][4]

    Anyone any ideas on this or maybe a fresh, better idea?

    Thanks in advance,
    Chris
    My Website
    010100010011110101110100011011110111000001101000

  • #2
    Not 100% sure about this, but you might get away with:

    Code:
    foreach $todo (@todos) {
    	push(@the_todos, @{ [ split(/\|/, $todo) ] });
    }
    - Mark
    [ AstroBoy Online | Experiments in Stuff | Google, use it! ]

    Comment

    Working...
    X