【问题标题】:Push into an array elements of textbox推入文本框的数组元素
【发布时间】:2014-05-07 06:41:21
【问题描述】:

我有一个文本框:

<input type="text" name="dropdiv" id="dropdiv" style="width:605" />

它包含更多标签(元素,例如:第一个标签最后一个标签第二个标签),以及如何在使用 CodeIgniter 插入数据库后将元素放入数组中?

谢谢

【问题讨论】:

  • 如果原始输入类似于tag1 tag2 tag3,那么只需explode()
  • 请详细说明您想做什么
  • 将文本框中的元素放入数组中,然后插入数据库中的表中。我有表文章、标签、tag_in_articles,我想为文章关联项目

标签: php codeigniter codeigniter-2


【解决方案1】:

尝试使用implode 获取字符串

<input type="text" name="tags" value="<php echo implode(",", $tags); ?>" />

并分解标签以保存数据库:

$tags = array_map('trim', explode(',', $this->input->post('tags')));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-17
    相关资源
    最近更新 更多