Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2011
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can i remove '=' sign and white space from end of a each line in a multiline text

    Hi there,

    I have a text like
    $line=`line1=
    line2=
    line3=`;

    it shows in browser like line1= line2= line3= . I want to remove the = sign and the extra space from the text. How can i remove it? if anyone knows please help me. I wish to display the output in browser like line1line2line3. Thanks in advance,,

  • #2
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    PHP Code:
    $line1 "line 1";
    $line2 "line 2";
    $line3 "line3";

    echo 
    "$line1";
    echo 
    "$line2";
    echo 
    "$line3"
    Is that what you meant?

  • #3
    New Coder
    Join Date
    Mar 2011
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi stevenmw,

    No,
    that is a multi line text for example like

    $string ='Lorem Ipsum is simply dummy text of the=
    printing and typesetting industry=
    Lorem Ipsum has been the industrys=
    standard dummy text ever since the 1500s=
    when an unknown printer took a galley of type and scrambled=
    it to make a type specimen book. It has survived not only five centuries=
    but also the leap into electronic typesetting, remaining essentially unchanged=
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, =
    and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum=';

    and i am trying to remove the '=' sign and white space from each line.

  • #4
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    Can you post your code?

    PHP Code:
    $line="line1 line2 line3"
    I would think this would work?

    The = is obviously because it is inside of the variable. I would think the spacing is due to the code being on separate lines.
    Last edited by stevenmw; 02-25-2012 at 06:12 AM.

  • #5
    New Coder
    Join Date
    Mar 2011
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi stevenmw,

    Thanks for the reply,
    Finally i have found the solution .

    $line=`line1=
    line2=
    line3=`;

    $line = preg_replace("/=\s+/","",$line);
    $line = substr_replace($line, '',-1);

    Thank you very much for your updates.


  •  

    Tags for this Thread

    Posting Permissions

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