Skip to content

Instantly share code, notes, and snippets.

@fouedmoussi
Created February 19, 2020 13:13
Show Gist options
  • Save fouedmoussi/191d929b2790909d3ae9614da465cce8 to your computer and use it in GitHub Desktop.
Save fouedmoussi/191d929b2790909d3ae9614da465cce8 to your computer and use it in GitHub Desktop.
Creating a slug from Arabic letters
<?php
$stringParts = array_values(array_filter(explode(" ", 'مقالة جديدة')));
$slug = '';
foreach ($stringParts as $key => $string) {
$hyphen = ($key < sizeof($stringParts) - 1) ? '-' : '';
$slug .= $string . $hyphen;
}
var_dump($slug);
// "مقالة-جديدة"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment