I have a variable that breaks and it breaks when viewing the page source. How would I have the variable join together into one line when I view the page source.

Viewing The Source From:
This
is my sentence.

Viewing The Source To:
This is my sentence.

<?php
$test = "This
is my sentence.";

$text = explode("\n",$test);

echo trim($text[0].$text[1]);
?>

    Well, you could do...

    echo preg_replace('/\r?\n/', ' ', $test);
    

    However, it raises the question: does it really matter? A line-break in HTML is functionally no different than a space, unless the text is within <pre> tags or a <textarea> (or an element that has been styled with "white-space: pre;").

      Thanks NogDog, it works.

      I can't think of an easier way to find duplicates between two arrays with different formats with similar/same data using in_array.

        Dont forget to mark this thread as RESOLVED ...

          Write a Reply...