pastebin
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
pastebin
Follow @pastebin
create new paste
trending pastes
sign up
login
my settings
my profile
My Pastes
Public Pastes
Untitled
JavaScript | 7 sec ago
Rapidshare Premium acco...
22 sec ago
Please help with my pro...
20 sec ago
JizzBomb Amber Sun
20 sec ago
Untitled
38 sec ago
Untitled
23 sec ago
Untitled
29 sec ago
FilePost contas premium...
33 sec ago
Layout Width
Share Pastebin
jeff_
By: a guest | Jun 15th, 2009 | Syntax:
PHP
| Size: 0.75 KB | Hits: 238 | Expires: Never
Download
|
Raw
|
Embed
|
Report abuse
$page
=
file_get_contents
(
'ton gros fichier.xhtml'
)
;
// ici nettoyage du code pour ne garder que ce qui est entre les balises "body"
preg_match_all
(
'#<h([2])[^>]{0,}>(.*)</h\1>#i'
,
$page
,
$match
)
;
$match
=
$match
[
0
]
;
$summary
=
array
(
)
;
foreach
(
$match
as
$m
)
{
$page
=
str_replace
(
$m
,
'<!-- cut here -->'
.
$m
,
$theContent
)
;
// on place un marqueur de découpe
$summary
[
]
=
striptags
(
$m
)
;
// on stocke les titres pour créer une page index
}
$page
=
explode
(
'<!-- cut here -->'
,
$page
');
foreach ($page as $num=>$chunk) {
file_put_contents($num.'
.
html
',$chunk);
}
$index = '
';
foreach ($summary as $num=>$entry) {
$index.='
<
li
><
a href
=
"'.
$num
.'.html"
>
'.$entry.'
</
a
></
li
>
}
$index
=
'<ul>'
.
$index
.
'</ul>'
;
file_put_contents
(
'index.html'
,
$index
)
;
create new paste
|
create new version of this paste
RAW Paste Data