Jump to content

How can i concat two string removing newline characters from mddle of the string


colap

Recommended Posts

The older way of doing this, with gconftool-2 doesn’t seem to work anymore in GNOME 3 – used to be something like:<br /><br />
However, there is still possible to change the background image, by using the gsettings tool instead. You will need the libglib2.0-bin package, which is probably already installed on your system. To change the background, use a command like the following:

 

I need to convert the string into=>

The older way of doing this, with gconftool-2 doesn’t seem to work anymore in GNOME 3 – used to be something like:<br /><br />However, there is still possible to change the background image, by using the gsettings tool instead. You will need the libglib2.0-bin package, which is probably already installed on your system. To change the background, use a command like the following:

 

How can i do this ? How can i remove that newline character from the middle of the string and concat those two lines and make into one sentence?

You could use:

 


$string = 'The older way of doing this, with gconftool-2 doesn’t seem to work anymore in GNOME 3 – used to be something like:<br /><br />However, there is still possible to change the background image, by using the gsettings tool instead. You will need the libglib2.0-bin package, which is probably already installed on your system. To change the background, use a command like the following:';


$patterns = array();
$patterns[0] = '|<br /><br />|';

$replacements = array();
$replacements[2] = '';

echo preg_replace($patterns, $replacements, $string);


 

That will remove any insteance of your double line break. However, if you're going to use it a bit more widely then you might want to make the regular expression a bit cleverer in that it will currently match precisely the way

 

<br /><br />

is written - spaces and all.

 

But should set you on the right path :)

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.