jonprasetyo
jonprasetyo

Reputation: 3586

How to include the slash at the end of base_url Codeigniter

So I have a dynamic link and I wanted to write the dynamic link like this:

echo "<a href='".base_url('browse/category/').$all_categories[$j]['id']."'>";

However the link appears to be like this...

www.example.com/browse/category2

There is no slash between the category and the dynamic number (2). So i figured another way but i think it is a messy way like this:

base_url('browse/category')."/".$all_categories[$j]['id']

Is there a better way to do this??

Many thanks!

Upvotes: 0

Views: 449

Answers (2)

Pavan Kumar
Pavan Kumar

Reputation: 406

echo base_url().'browse/category/'.$all_categories[$j]['id']);

This is another way

Upvotes: 0

Nil&#39;z
Nil&#39;z

Reputation: 7475

Try this:

echo base_url('browse/category/'.$all_categories[$j]['id']);

Output:

http://example.com/browse/category/2

Upvotes: 5

Related Questions