SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding a character

    Hi.

    I have a multi-line variable, and I need to add a character to the beginning of each line in the variable. How would I go about doing this? I'm sure it takes a simple function...I just haven't found it yet.

    Thanks.

  2. #2
    SitePoint Addict BenANFA's Avatar
    Join Date
    Apr 2003
    Location
    Bath, UK
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $yourText GetText();

    /* Put your character here */
    $start_of_line "Start of Line";

    $yourText str_replace "\n""\n$start_of_line"$yourText );

    /* Insert on first line if required */
    $yourText $start_of_line $yourText


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
  •