SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding text to a php variable

    Hello,

    Could someone advise me on how to add text so it appears straight after a php vairable.

    If I have a variable called $menu (containing text 'pop') and I want 1 to appear after it how do I make this happen. Ie so that pop1 is displayed.

    If I have echo $menu1 then obviosuly it wont display as it thinks that menu1 is a variable,

    Cheers.
    Eternity

  2. #2
    SitePoint Zealot dbworm's Avatar
    Join Date
    Apr 2003
    Location
    Lausanne
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kjc
    Hello,
    If I have a variable called $menu (containing text 'pop') and I want 1 to appear after it how do I make this happen. Ie so that pop1 is displayed.
    Cheers.
    Try:

    $menu = "pop";
    $menu .= "1";

    or

    $menu = $menu . "1";

    echo "$menu" // both solutions return "pop1"

  3. #3
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo $menu ."1";
    or
    echo "{$menu}1";

  4. #4
    SitePoint Addict
    Join Date
    Oct 2002
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Briliant

    Thats great thankyou
    Eternity


Bookmarks

Posting Permissions

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