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

02-25-2012, 04:42 AM
Hi there,

I have a text like

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,,

02-25-2012, 05:28 AM
$line1 = "line 1";
$line2 = "line 2";
$line3 = "line3";

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

02-25-2012, 05:39 AM
Hi stevenmw,

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.

02-25-2012, 05:45 AM
Can you post your 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.

02-25-2012, 07:14 AM
Hi stevenmw,

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


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

Thank you very much for your updates.