Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: how can I prepend a string?

  1. #11
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Also is more efficient.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #12
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Though you now have your answer, you've entirely overthought this:
    $a = 'abc'; $b = 'xyz';
    $a.$b becomes 'abcxyz'

    To insert a space, that is another step, using $a.' '.$b

    And of course you'll have to pick what value is $a, and what is $b.

    In short, using the . operator will add two strings.

    And as Twey has pointed out, the .= is just a shortcut to $a = $a.$b;. There is no shortcut for using =., and equivalent of $a = $b.$a;
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •