10-05-2011
well assuming the text you want to transform is stored in a string variable. Something like this.
PHP Code:
$text = "Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah
Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.";
$lines = preg_split('/\r\n|\r|\n', $text);
$text2 = "";
foreach($lines as $line)
{
if($line!="")
$text2 .= "<h2>".$line."</h2>\r\n";
}
// The text will then be stored in $text2 with the h2 tags in place
//do what you want with it say:
echo $text2;
Hope this is what you meant. Unless you meant you want to split up where there is a <p>?
8 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Guys,
I am trying to write a perl script to search a string "Name" in the file "FILE" and also want to create a new file and push the searched string Name line along with 10 lines following the same.
can anyone of you please let me know how to go about it ? (8 Replies)
Discussion started by: sukrish
8 Replies
2. Solaris
I get a file which has all its content in a single row.
The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file.
I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
Discussion started by: ducati
4 Replies
3. UNIX for Dummies Questions & Answers
I tried line wrap in sed by sed -l 20 ' n' and as far as i understand each long line would be split into lenght of 20 characters in each. but thats not happening.wats going wrong:confused: (5 Replies)
Discussion started by: mithun1!
5 Replies
4. Shell Programming and Scripting
I am very new to shell scripting, current try to do a sorting of a text file in paragraphs with ksh script.
example:
File content:
A1100001 line 1 = "testing"
line 2 = something,
line 3 = 100
D1200003 line 1 = "testing"
line 2 = something,
line 3 = 100
B1200003 line 1 =... (3 Replies)
Discussion started by: gavin_L
3 Replies
5. Shell Programming and Scripting
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB and add/replace... (1 Reply)
Discussion started by: suryanarayana
1 Replies
6. Shell Programming and Scripting
Dear All
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB... (5 Replies)
Discussion started by: suryanarayana
5 Replies
7. Red Hat
Hi,
I have a file which is an extract of jil codes of all autosys jobs in our server.
Sample jil code:
**************************
permission:gx,wx
date_conditions:yes
days_of_week:all
start_times:"05:00"
condition: notrunning(appDev#box#ProductLoad)... (1 Reply)
Discussion started by: raghavendra
1 Replies
8. Shell Programming and Scripting
Hello everybody
I have a text file which has the following format:
nmm "text20140601.033954text" "text" "text"
"text" , ... , "text"
"text" , ... , Lat 36.3247 Lon 16.0588 Depth 8
"text", ... , "text"
"text", ..., CovXX 1.65 CovYY 2.32 CovZZ 1.2
"text" , ..., "text
nmm ... (6 Replies)
Discussion started by: phaethon
6 Replies
LEARN ABOUT DEBIAN
time::duration::parse
Time::Duration::Parse(3pm) User Contributed Perl Documentation Time::Duration::Parse(3pm)
NAME
Time::Duration::Parse - Parse string that represents time duration
SYNOPSIS
use Time::Duration::Parse;
my $seconds = parse_duration("2 minutes and 3 seconds"); # 123
DESCRIPTION
Time::Duration::Parse is a module to parse human readable duration strings like 2 minutes and 3 seconds to seconds.
It does the opposite of duration_exact function in Time::Duration and is roundtrip safe. So, the following is always true.
use Time::Duration::Parse;
use Time::Duration;
my $seconds = int rand 100000;
is( parse_duration(duration_exact($seconds)), $seconds );
FUNCTIONS
parse_duration
$seconds = parse_duration($string);
Parses duration string and returns seconds. When it encounters an error in a given string, it dies an exception saying "Unknown
timespec: blah blah blah". This function is exported by default.
AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
COPYRIGHT
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Some internal code is taken from Cache and Cache::Cache modules on CPAN.
SEE ALSO
Date::Manip, DateTime::Format::Duration, <http://use.perl.org/~miyagawa/journal/30310>
perl v5.10.0 2008-06-02 Time::Duration::Parse(3pm)