{"id":971,"date":"2010-10-04T21:11:28","date_gmt":"2010-10-04T21:11:28","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=971"},"modified":"2010-10-04T21:13:15","modified_gmt":"2010-10-04T21:13:15","slug":"how-to-explode-a-string-and-create-hyperlink","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2010\/10\/how-to-explode-a-string-and-create-hyperlink\/","title":{"rendered":"How to explode a string and create hyperlink?"},"content":{"rendered":"<p>Here is very easy code to create Tagged List with hyperlink.<br \/>\nI have found several events where we have to create dynamic URL with Tagged text.<br \/>\nI have used very simple approach. Just Exploded sting and replaced space with &#8220;-&#8221;<br \/>\nYou can use PHP function preg_replace() or str_replace() then used here-docs for creating hyperlink.<br \/>\nInstead of Echo Hear Docs is much better solution.<br \/>\nAnd at last removed the last Comma, and return your comma separated Dynamic links.<\/p>\n<pre lang=\"php\">\r\n$tags = \"jQuery Tutorials, PHP Display Errors, Drupal Module\";\r\n$tagL=\"\";\r\nfunction b2b_article_LinkedTags($stringTags) {\r\n\t$expTags = explode(\",\",$stringTags);\r\n\tforeach($expTags as $key=>$Tagevalue) {\r\n\t$Tagevalue = trim($Tagevalue);\r\n\t$link = preg_replace('\/[^-a-z0-9]\/', '-', strtolower($Tagevalue) );\r\n\t\/\/$link = str_replace(\" \",\"-\", strtolower($Tagevalue));\r\n\t$tagL.=<<<EOF\r\n\t   <a href=\".\/articles-tagged-$link\">$Tagevalue<\/a>,\r\nEOF;\r\n\t}\r\n\t\r\n\treturn substr($tagL, 0, -1);\r\n}  \r\necho b2b_article_LinkedTags($tags)\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is very easy code to create Tagged List with hyperlink. I have found several events where we have to create dynamic URL with Tagged text. I have used very simple approach. Just Exploded sting and replaced space with &#8220;-&#8221; You can use PHP function preg_replace() or str_replace() then used here-docs for creating hyperlink. Instead [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20,3],"tags":[],"class_list":["post-971","post","type-post","status-publish","format-standard","hentry","category-easy-php","category-php"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=971"}],"version-history":[{"count":2,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/971\/revisions"}],"predecessor-version":[{"id":973,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/971\/revisions\/973"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}