Click here to Skip to main content
12,823,823 members (58,632 online)
Rate this:
Please Sign up or sign in to vote.
See more: PHP MySQL
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.)

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 13-Mar-12 19:04pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can use implode/explode.

Try using <br> or \n as separator and use it twice where you want it as a blank line.
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 14 Mar 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100