Results 1 to 2 of 2

Thread: [RESOLVED] function, increase a number in variable?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    1,023

    Resolved [RESOLVED] function, increase a number in variable?

    i'm trying to make a number increase inside a function, but i got a problem, the number won't go higher then 1 and i can't figure this out... this is the code i've got so far:

    PHP Code:
    function increase($test)
    {
    global 
    $nr;// global variable
    $nr++;
    echo 
    $test "<br />";
    echo 
    $nr "<br />";
    }

    increase("test1");
    increase("test2"); 
    edit i figured out a solution...
    i just needed to add global $nr; to the code.
    Last edited by Justa Lol; Jan 29th, 2010 at 06:33 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width