如何在字符串中插入和检索空行 [英] How to Insert and Retrieve Empty Line into a string

查看:73
本文介绍了如何在字符串中插入和检索空行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.
我想在字符串中插入空白/空行,然后将其添加到Mysql数据库中.
例如

1.
I want to Insert a blank / Empty Line into a string and then I have to add this string into the Mysql database
For example

$str1 = "This is the first string";
$str2 = "This is the second string";
$final_string = $str1 . <blank line> . $str2;


该字符串的输出必须像这样


The output of this string must be like this

This is the first string

This is the second string 



我应该在两个字符串之间使用什么来插入空白行
注意:(我不想使用html< br/>标记,因为它会原样添加到数据库中.)

2.
我必须在空行的基础上转换字符串
字符串就像



What should I use between the both strings to insert a blank line
Note: (I don''t want to use the html <br /> tag because it will be added to the database as it is.)

2.
I Have to convert the string on the base of the blank line
The string is such like

This is the first line
This is the second line
This is the third line
This is the forth line

This is the fifth line
This is the Sixth line
This is the seventh line


我必须将此字符串转换为数组.数组必须将前四行(在空行之前)作为其第一元素,并将其余三行(在空行之后)作为其第二元素.

我想使用explode()函数将此字符串转换为数组
但是我的问题是,我应该在explode()函数中使用什么作为分隔符,因为字符串中的分隔符为空行.


I have to convert this string to an array. The Array must have the first four lines (before the blank line) as its first element and the rest of the three lines (after the blank line) as its second element.

I want to use the explode() function to convert this string into an array
But MY Question is what should I use in explode() function as a separator because the separator in the string is blank line.


推荐答案

str1 =这是第一个字符串";
str1 = "This is the first string";


str2 =这是第二个字符串" ;
str2 = "This is the second string";


final_string =
final_string =


这篇关于如何在字符串中插入和检索空行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆