简体   繁体   中英

How line break content become one line paragraph?

* strong text *what i want to do is from my breakline content to one line paragraph

example my var_dump result:

string(212) "(73857,"2012-02-02 03:18:44","TXT",60143836234);"

string(122) "(73858,"2012-02-02 03:20:08","WAP",60143836234);"

string(211) "(73859,"2012-02-02 08:21:47","TXT",60163348563,);"

What i want to become:

string(555) "(73857,"2012-02-02 03:18:44","TXT",60143836234);(73858,"2012-02-02 03:20:08","WAP",60143836234);(73859,"2012-02-02 08:21:47","TXT",60163348563,);"

update (here is my code, $i is the line break records, if I able to make the breakline to one line, i will put in a new file )

foreach($get_line_feed_content as $i) {
$add_special_char = "(".$i.");";

var_dump($add_special_char);

    if(!empty($i)){


        $stringData = $final_content;
        fwrite($save, $stringData);
        fclose($save);
    }
}

any idea?

Thank and highly appreciated your answer

Did you just want to glue the strings together? I don't see any line breaks from your dumps.

If that's the case, just do:

$finalString = $string1 . $string2 . $string3;
var_dump($finalString); //Strings should be glued as one.

If, however, each line is represented as an element in an array:

$stringsArray = array('string1', 'string2', 'string3');
$finalString = implode("", $stringsArray);
var_dump($finalString);

With your most recent update, this is what I would do:

$newString = '';

foreach($get_line_feed_content as $i) { 
  $newString  .= "(".$i.");"; //concatenate

  var_dump($newString); //You will get a lot of dumps and with each dump, a new string should be appended to it. 

    if(!empty($i)){ 
        fwrite($save, $newString); 
        fclose($save); 
    } 
} 

if you want to glue strings you can do like this:

$data = $string1.$string2.$string3;

If you have array of strings do like this:

$strings = array('text1','text2','text3');
$data = implode('', $strings);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM