The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 10 of 10

Thread: PHP variable within variable

  1. #1
    Vexir's Avatar
    4,185
    posts
    Coming and going.

    PHP variable within variable

    I have this variable: $somecontent

    I want to put the value of a bunch of other variables into it...

    I tried

    $somecontent = '$_POST[\'opponent\'] $_POST[\'type\'] $_POST[\'map\'] $_POST[\'winlose\']
    $_POST[\'yourscore\'] $_POST[\'theirscore\'] $_POST[\'mvp\']\n';

    But that just outputted (when echoed)

    $_POST[\'opponent\'] $_POST[\'type\'] $_POST[\'map\'] $_POST[\'winlose\']
    $_POST[\'yourscore\'] $_POST[\'theirscore\'] $_POST[\'mvp\']\n

    How come?

  2. #2
    do u want an array, or do u want to tie together the various variables to form one long string or wat?

  3. #3
    Vexir's Avatar
    4,185
    posts
    Coming and going.
    tie them together to form a string which is stored in $somecontent

  4. #4
    Uh... Maybe this is what you are looking for???
    PHP Code:
    $somecontent $_POST['opponent'] . $_POST['type'] . $_POST['map'] . $_POST['winlose'] . $_POST['yourscore'] . $_POST['theirscore'] . $_POST['mvp'] . '\n'
    CyanBlue / Jason Je / Flash Developer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com

  5. #5
    Vexir's Avatar
    4,185
    posts
    Coming and going.
    Ahh yeah thanks a lot

  6. #6
    Just make sure that you need to use . (dot) to concatenate the strings in PHP... and that won't be that visible if you wear four eyes like I do...

    Glad to be of service...
    CyanBlue / Jason Je / Flash Developer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com

  7. #7
    amitgeorge's Avatar
    646
    posts
    -1 posts per day. Huh ?
    btw the problem with your code was

    $somecontent = '$_POST[\'opponent\'] $_POST[\'type\'] $_POST[\'map\'] $_POST[\'winlose\']
    $_POST[\'yourscore\'] $_POST[\'theirscore\'] $_POST[\'mvp\']\n';

    should be

    $somecontent = "$_POST[opponent] $_POST[type] $_POST[map] $_POST[winlose]
    $_POST[yourscore] $_POST[theirscore] $_POST[mvp]\n";

    notice the quotes

  8. #8
    ekhrm...

    $somecontent = "$_POST['opponent'] $_POST['type'] $_POST['map'] $_POST['winlose']
    $_POST['yourscore'] $_POST['theirscore'] $_POST['mvp']\n";

  9. #9
    Vexir's Avatar
    4,185
    posts
    Coming and going.
    AH i see.

  10. #10
    amitgeorge's Avatar
    646
    posts
    -1 posts per day. Huh ?
    Quote Originally Posted by fluid_tw0
    ekhrm...

    $somecontent = "$_POST['opponent'] $_POST['type'] $_POST['map'] $_POST['winlose']
    $_POST['yourscore'] $_POST['theirscore'] $_POST['mvp']\n";
    whats ekhrm ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012