A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: $variable{$var2} ???

  1. #1
    Member
    Join Date
    Jul 2003
    Location
    Earth
    Posts
    74

    $variable{$var2} ???

    Hi all!

    does anybody have an idea what the syntax on the 3rd line has to mean?
    It's a part of a email address obfuscation function:

    PHP Code:
    $inprogresskey "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@";
    $ranpos rand(0$unshuffled 1);
    $nextchar $inprogresskey{$ranpos}; 
    By the way, it causes an error. (Uninitialized string offset: 0)
    The whole function used to work in the past, as far as I suppressed all the PHP errors. Now I'm trying to figure out what that line was meant to be, in order to rewrite it.

    thanks for your wisdom!

  2. #2
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    the third line act as an array of $inprogresskey variable and $ranpos creates a random number of that array.
    If you test with a echo $nextchar; with a value in $unshuffled. you can see the result.

    {} or [] act same in php array.

    marlopax

  3. #3
    Member
    Join Date
    Jul 2003
    Location
    Earth
    Posts
    74
    Thanks!

    I didn't know that {} acts the same way as []. Now I can understand the code.

    Thank to your hint I was able to localized the error: a loop was calling the array just once more than it should...


    Cheers,
    Nominee

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