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
C++ | 2 sec ago
Untitled
3 sec ago
Enjoy Minnesota Timberw...
48 sec ago
Untitled
8 sec ago
***%%WaTcH France vs Un...
23 sec ago
FilePost cuentas premiu...
10 sec ago
Untitled
15 sec ago
Untitled
21 sec ago
Layout Width
Share Pastebin
jeff_
By: a guest | Jun 16th, 2009 | Syntax:
PHP
| Size: 0.75 KB | Hits: 89 | Expires: Never
Download
|
Raw
|
Embed
|
Report abuse
This paste has a previous version,
view the difference
.
$page
=
file_get_contents
(
'charron.html'
)
;
// 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
[
]
=
strip_tags
(
$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