1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# URLify for PHP
A PHP port of [URLify.js](https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/urlify.js)
from the Django project. Handles symbols from Latin languages, Greek, Turkish,
Russian, Ukrainian, Czech, Polish, and Latvian. Symbols it cannot transliterate
it will simply omit.
* Author: [jbroadway](http://github.com/jbroadway)
* License: MIT
## Usage:
To generate slugs for URLs:
```php
<?php
echo URLify::filter (' J\'étudie le français ');
// "jetudie-le-francais"
echo URLify::filter ('Lo siento, no hablo español.');
// "lo-siento-no-hablo-espanol"
?>
```
To simply transliterate characters:
```php
<?php
echo URLify::downcode ('J\'étudie le français');
// "J'etudie le francais"
echo URLify::downcode ('Lo siento, no hablo español.');
// "Lo siento, no hablo espanol."
/* Or use transliterate() alias: */
echo URLify::transliterate ('Lo siento, no hablo español.');
// "Lo siento, no hablo espanol."
?>
```
To extend the character list:
```php
<?php
URLify::add_chars (array (
'¿' => '?', '®' => '(r)', '¼' => '1/4',
'¼' => '1/2', '¾' => '3/4', '¶' => 'P'
));
echo URLify::downcode ('¿ ® ¼ ¼ ¾ ¶');
// "? (r) 1/2 1/2 3/4 P"
?>
```
To extend the list of words to remove:
```php
<?php
URLify::remove_words (array ('remove', 'these', 'too'));
?>
```
|