Browse posteets
About
Contact us
Log In
Register
View: Formater une URL proprement pour URL Rewriting
Formater une URL proprement pour URL Rewriting
11 months ago
by
mikaweb
and saved by
1 other
function
format_url
(
$url
,
$type
=
''
)
{
$url
=
preg_replace
(
"`
\[
.*
\]
`U"
,
""
,
$url
)
;
$url
=
preg_replace
(
'`&(amp;)?#?[a-z0-9]+;`i'
,
'-'
,
$url
)
;
$url
=
htmlentities
(
$url
, ENT_COMPAT
)
;
$url
=
preg_replace
(
"`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i"
,
"
\\
1"
,
$url
)
;
$url
=
preg_replace
(
array
(
"`[^a-z0-9]`i"
,
"`[-]+`"
)
,
"-"
,
$url
)
;
$url
=
(
$url
==
""
)
?
$type
:
strtolower
(
trim
(
$url
,
'-'
)
)
;
return
$url
;
}
php
uri
url rewriting
View source
0 comment
about "Formater une URL proprement pour URL Rewriting"
Tags
php
uri
url rewriting
Note
Il vous suffit ensuite de déclarer ainsi function format_url();
0 comment about "Formater une URL proprement pour URL Rewriting"