Click here to Skip to main content
15,888,257 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 


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

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.

Posted

1 solution

You can use implode/explode.
Ref:http://www.w3schools.com/php/func_string_implode.asp[^]
http://www.w3schools.com/php/func_string_explode.asp[^]

Try using <br> or \n as separator and use it twice where you want it as a blank line.
 
Share this answer
 
v3
Comments
rashidfarooq 14-Mar-12 1:36am    
but if I use <br> or \n it will be added to database as it is. I want to insert a blank line in the database not \n or <br>.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900