/    Sign up×
Community /Pin to ProfileBookmark

Splitting HTML Content

Hello all, here’s one for you.

I have a very large quantity of text that was converted to HTML. Nothing fancy, no CSS, just tags added here and there (italics, bold, paragraphs) for formatting.

I want to split these large text quantities into smaller individual files to display one at a time, much like pages of a book.

However, does anyone know a good way to parse out so I don’t split words or leave tags hanging open?

Just curious, I can live with plain text, but I’d love to not have to convert all of this and loose formatting.

Oh and alternate languages are fine, I just use PHP a lot so I was hoping to find an answer here.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@themartySep 08.2006 — you say it has paragraphs: you could explode on the </p> tag. That way you're sure the parts you get are meaningfull. You could do an additional loop through the array you create that way and determine with strlen() if the parts are big enough and if not, to join it with the next part. And of course to add the </p> tag again.
×

Success!

Help @PineSolPirate spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...