A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: PHP evaluating variables ?

  1. #1
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665

    PHP evaluating variables ?

    If I send multiple variables to a PHP script from flash say:
    $test1
    $test2
    $test3
    $test4
    and I want to loop through these with a while count so say:
    While($count<4){
    $test.="$count";
    $test (do something);
    $count++;
    }
    how could this be done?
    in Other words I want multiple vars with only number varying, and be able to use the aditition of the count to access the variables, unfortunately I am not good enough to work this out. Have tried everything.
    Musicman??
    Anyone??
    I know this must have something to do with using a function, variable variables dont work, and when I use the function command it can not be set within the while loop,
    cheers
    audas
    peace.

  2. #2
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    $ordernum =& $GLOBALS["ordernum".$count];
    Sorry worked it out.
    peace.

  3. #3
    Senior Member Wancieho's Avatar
    Join Date
    May 2002
    Posts
    370
    You could also try something like this:

    Code:
    while($i<4){
         $i++;
         $_POST["test".$i] = "blah";
         echo $_POST[test1];
    }

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    another one...

    $varname = "test4";
    now you can use $$varname

    Musicman

  5. #5
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    Musicman, i tried the variable variable but that didnt work???
    Thanks though, what about Browsing files direct from flash??
    peace.

  6. #6
    Member
    Join Date
    Mar 2000
    Posts
    91
    PHP Code:
    <?php

    $test1 
    'This is';
    $test2 'a sample';
    $test3 'script that will';
    $test4 'surely work!!';

    $varPrefix 'test';
    $varIndex 3;
    $output = ${$varPrefix $varIndex};

    echo 
    $output;

    ?>
    [Output]
    script that will

  7. #7
    go blues ! audas's Avatar
    Join Date
    Oct 2000
    Location
    london ,piccadily circus!
    Posts
    665
    Ok, fisrt of all it has to be inside a loop of varying lengths, we do not know how many times it will loop, I have tried the variable variable inside a loop with a variable loop counter and it didnt like it.
    But thanks anyway torray.
    my solution seemed to work well.
    peace.

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

HTML5 Development Center