从Codeigniter中的标题创建有效的URL

guz6ccqo  于 2023-03-16  发布在  其他
关注(0)|答案(1)|浏览(135)

我正在创建网址形式我张贴的标题。这里是一些样本标题。

标题示例:

$title = "Global Campaign Manager - (SEO and Advertising)";
$title = "Broadcast Journalist, BBC News Online (London)";
$title = "Agile Digital Project Manager/£475 - 525 pd/6 months/London";

现在,这里是URL的例子,我期待的形式这个标题.

预期URL:

www.example.com/global_campaign_manager_-_seo_and_advertising
www.example.com/agile_digital_project_manager475_-_525_pd6_monthslondon
www.example.com/broadcast_journalist_bbc_news_online_london
ee7vknir

ee7vknir1#

要将任何标题或文本转换为url代码,igniter具有URL Helper
此帮助器是使用以下代码加载的:

$this->load->helper('url');

现在,要将字符串转换为正确的URL。用户url_title

$title = "Agile Digital Project Manager/£475 - 525 pd/6 months/London";
$url_title =  url_title($title, 'underscore');

结果URL

www.example.com/agile_digital_project_manager475_-_525_pd6_monthslondon

相关问题