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?

Link to comment
Share on other sites

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 :)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.