显示标签和关联id


Show tags and an associative id

我有一个问题…我想用回显显示tag_name和id:我的数组:

 Array
 (
 [id] => 15
 [title] => This is the first article
 [content] => 
This is the first articleThis is the first articleThis is the first articleThis is the    first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first articleThis is the first article
[date] => 2014-05-11 12:05:00
[views] => 0
[smallimage] => Hydrangeas-11.jpg
[largeimage] => Hydrangeas-11.jpg
[tags] => first tag,last tag,second tag
[id_tag] => 15,16,17
)

我试过了,但是当我链接我进入浏览器:localhost/blogCI/tag/15,16,17,但我需要显示localhost/blogCI/tag/15或localhost/blogCI/tag/16我的代码:

<div class="news-content-title">
            <? echo $main_info['title'];?>
        </div>
        <div class="news-content-content">
            <? echo $main_info['content'];?>
        </div>

        <?php foreach($main_info as $n):?>
                        <?php $tags = explode(",", $n['tags']); ?>
                        <?php $id_tag = explode(",", $n['id_tag']); ?>
        <?php endforeach ?>
        <?php for ($i=0;$i<count($id_tag);$i++): ?>
                    <a href="<?php echo base_url('tag/'.$main_info['id_tag'])?>"><?php echo $main_info['tags'] ?></a>
        <?php endfor; ?>

请帮帮我

我不是特别确定语法,因为我没有使用codeigniter,但你可以试试这个:

<?php
      $tags['tags'] = explode(",",$main_info['tags']);
      $tags['id_tag'] = explode(",",$main_info['id_tag']);
         foreach($tags['tags'] as $k=>$v): ?>
           <a href="<?php echo base_url('tag/'.$tags['id_tag'][$k])?>"><?php echo $v ?></a>
         <?php endforeach ?>