Skip to content

Commit

Permalink
Added Arabify Functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zymawy committed Feb 12, 2019
1 parent 11f91a0 commit e15877c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Arabify.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: ironside
* Date: 2/12/19
* Time: 3:32 PM
*/
namespace Zymawy\Arabify;

class Arabify {

public function arabify($title = null, $separator = "-")
{
$title = trim($title);
$title = mb_strtolower($title, 'UTF-8');

$title = str_replace('', $separator, $title);

$title = preg_replace(
'/[^a-z0-9_\s\-اآؤئبپتثجچحخدذرزژسشصضطظعغفقكکگلمنوةيإأۀءهی۰۱۲۳۴۵۶۷۸۹٠١٢٣٤٥٦٧٨٩]/u',
'',
$title
);

$title = preg_replace('/[\s\-_]+/', ' ', $title);
$title = preg_replace('/[\s_]/', $separator, $title);
$title = trim($title, $separator);

return $title;
}
}

0 comments on commit e15877c

Please sign in to comment.