Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP 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 
 
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 13-Mar-12 18:04pm

1 solution

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

Solution 1

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.
  Permalink  
v3
Comments
rashidfarooq at 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
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 166
2 PhilLenoir 164
3 Richard MacCutchan 160
4 Sharmanuj 146
0 Sergey Alexandrovich Kryukov 6,081
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 14 Mar 2012
Copyright © CodeProject, 1999-2014
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