Wierd PHP String Manipulation Issue

nick-harper

New member
Hi guys,

I am using ckeditor on a site which works great but it keeps putting the code like this:

Code:
    <p>
            Testing the RSS Feed out and the paragraphs.</p>

The thing is, I need it to look like this:

Code:
    <p>Testing the RSS Feed out and the paragraphs.</p>

How would I go about doing a string replace to simply just remove that little gap?

Thanks
 


Try downloading the site with wget. This might be a browser issue (as in: the browser puts that line in the rendering, not ckEdit)

::emp::
 
i don't think there is an issue if it keeps looking like this?... or will it render pages differently,?.. i think there are some empty spaces and tabs that needs to be removed.

cheers!
 
Try trim()

Trim would only handle the outsides of the string.

If that's the string and you can isolate it, I'd try this:

Code:
<?php

$string; //you're awkward string, simply here for reference
$string = '<p>' . trim(str_replace('<p>', '', $string));

?>

What it does is remove the <p> element and then trims the white space and appends the <p> back on the front.
 
Or you can do this:

Code:
$s = '<p>
            Testing the RSS Feed out and the paragraphs.</p>';

$s = preg_replace("/\n\s+/", "", $s);
 
Easy.

Code:
$text = trim(preg_replace("/<\/?p>/", "", $s));
$new_s = '<p>' . $text . '</p>';

Should do the trick. :)
 
I solved the problem by adding this instruction in the file ckeditor.js: n.setRules('p',{indent:false,breakAfterOpen:false});
....