{"id":669,"date":"2012-11-29T04:13:12","date_gmt":"2012-11-29T04:13:12","guid":{"rendered":"http:\/\/codeatelier.wordpress.com\/?p=395"},"modified":"2012-11-29T04:13:12","modified_gmt":"2012-11-29T04:13:12","slug":"seo-friendly-url-in-php","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/seo-friendly-url-in-php\/","title":{"rendered":"seo friendly url in php"},"content":{"rendered":"<pre>\nfunction seo($input)\n{\n    \/\/remove single quote and dash\n    $input = str_replace(array(\"'\", \"-\"), \"\", $input); \n\n    \/\/convert to lowercase\n    $input = mb_convert_case($input, MB_CASE_LOWER, \"UTF-8\"); \n\n    \/\/replace everything non an with dashes\n    $input = preg_replace(\"#[^a-zA-Z0-9]+#\", \"-\", $input); \n\n    \/\/replace multiple dashes with one\n    $input = preg_replace(\"#(-){2,}#\", \"$1\", $input);\n\n    \/\/trim dashes from beginning and end of string if any\n    $input = trim($input, \"-\"); \n    \n    \/\/voila\n    return $input; \n}\n<\/pre>\n<p>OP:<br \/>\necho seo(&#8220;Tom&#8217;s Fish &amp; Chips&#8221;); \/\/toms-fish-chips<br \/>\necho seo(&#8220;1-2-3 Pizza&#8221;); \/\/123-pizza<\/p>\n","protected":false},"excerpt":{"rendered":"<p>function seo($input) { \/\/remove single quote and dash $input = str_replace(array(&#8220;&#8216;&#8221;, &#8220;-&#8220;), &#8220;&#8221;, $input); \/\/convert to lowercase $input = mb_convert_case($input, MB_CASE_LOWER, &#8220;UTF-8&#8221;); \/\/replace everything non an with dashes $input = preg_replace(&#8220;#[^a-zA-Z0-9]+#&#8221;, &#8220;-&#8220;, $input); \/\/replace multiple dashes with one $input = preg_replace(&#8220;#(-){2,}#&#8221;, &#8220;$1&#8221;, $input); \/\/trim dashes from beginning and end of string if any $input =&hellip; <a href=\"https:\/\/codethataint.com\/blog\/seo-friendly-url-in-php\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,93],"tags":[],"class_list":["post-669","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-php"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=669"}],"version-history":[{"count":0,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/669\/revisions"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}