mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-06-06 02:13:13 +00:00
Remove duplicate tags
This commit is contained in:
parent
d8f2166a1f
commit
7308f669a5
1 changed files with 14 additions and 5 deletions
19
app/app.php
19
app/app.php
|
@ -30,15 +30,24 @@ class Make {
|
||||||
Returns clean string of words with equal white space between it
|
Returns clean string of words with equal white space between it
|
||||||
*/
|
*/
|
||||||
function tags($string) {
|
function tags($string) {
|
||||||
// Replace hyphens
|
|
||||||
$string = str_replace('-', '_', $string);
|
$string = str_replace('-', '_', $string);
|
||||||
// Regex
|
|
||||||
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
|
$string = preg_replace('/[^A-Za-z0-9\_ ]/', '', $string);
|
||||||
// Change to lowercase
|
|
||||||
$string = strtolower($string);
|
$string = strtolower($string);
|
||||||
// Removing extra spaces
|
|
||||||
$string = preg_replace('/ +/', ' ', $string);
|
$string = preg_replace('/ +/', ' ', $string);
|
||||||
|
|
||||||
|
$string = explode(" ", $string);
|
||||||
|
$string_list = array();
|
||||||
|
|
||||||
|
foreach ($string as $i) {
|
||||||
|
if (!in_array($i, $string_list)) {
|
||||||
|
$string_list[] = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$string = implode(" ", $string_list);
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue