PASTEBIN
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
PASTEBIN
create new paste
trending pastes
sign up
login
my alerts
my settings
my profile
Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free!
Click here to download the new Pastebin App for iOS
.
Public Pastes
Untitled
1 sec ago
Untitled
3 sec ago
Untitled
7 sec ago
Untitled
8 sec ago
Untitled
8 sec ago
Untitled
PHP | 11 sec ago
TowelDay
11 sec ago
Untitled
12 sec ago
jeff_
By: a guest on Jun 19th, 2009 | syntax:
PHP
| size: 0.80 KB | hits: 179 | expires: Never
download
|
raw
|
embed
|
report abuse
This paste has a previous version,
view the difference
.
Copied
<?
$page
=
file_get_contents
(
'./source/fichier.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
,
$page
)
;
// on place un marqueur de découpe
$summary
[
]
=
strip_tags
(
$m
)
;
// on stocke les titres pour créer une page index
}
print_r
(
$page
)
;
$page
=
explode
(
'<!-- cut here -->'
,
$page
)
;
foreach
(
$page
as
$num
=>
$chunk
)
{
file_put_contents
(
'./result/'
.
$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
(
'./result/index.html'
,
$index
)
;
?>
create a
new version
of this paste
RAW Paste Data