Slug Generator in PHP

Watch the following video to learn how to write a PHP code that convert your text to slug.

<?php
$string = "Ahmed alsaleh";
$slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string)));
echo $slug;
?>
coding | php | slug

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart