Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 提交自定义值和存在值并对其排序后的Tokeninput foreach值_Php_Jquery_Codeigniter_Submit_Jquery Tokeninput - Fatal编程技术网

Php 提交自定义值和存在值并对其排序后的Tokeninput foreach值

Php 提交自定义值和存在值并对其排序后的Tokeninput foreach值,php,jquery,codeigniter,submit,jquery-tokeninput,Php,Jquery,Codeigniter,Submit,Jquery Tokeninput,我使用来自的jQuery Tokeninput自动完成插件 当我试图将该值提交给我的php处理程序时,我不知道该怎么做 HTML <form action="<?=base_lang_url("addtags/test")?>" method="post"> <input id="tags" name="tags"> <input type="submit" value="Add"> </form> JSI只是想展示一下我是如何设置的

我使用来自的jQuery Tokeninput自动完成插件 当我试图将该值提交给我的php处理程序时,我不知道该怎么做

HTML

<form action="<?=base_lang_url("addtags/test")?>" method="post">
<input id="tags" name="tags">
<input type="submit" value="Add">
</form>
JSI只是想展示一下我是如何设置的,但我认为这并不重要

PHP

if(trim($this->input->post("room_tags")) != ""){
    $tags = explode(",",trim($this->input->post("room_tags")));
    foreach($tags as $value){
        if(preg_replace( "/[^0-9]/", "",$value)){
            $tag_int[] = $value;
        }else{
            $tag_string[] = $value;
        }
    }

    $this->load->model("tags_model");
    $tag_find = $this->tags_model->findTags($tag_int);

    if(is_array($tag_find) && is_array($tag_string)){
        $all_tags = array_merge($tag_find,$tag_string);
    }elseif(is_array($tag_find) && isset($tag_find)){
        $all_tags = $tag_find;
    }elseif(isset($tag_string) && is_array($tag_string)){
        $all_tags = $tag_string;
    }

    echo "<pre>";
        echo print_r($all_tags);
    echo "</pre>";
}
我喜欢这样:

echo '<pre>';



$all_tags_copy = $all_tags;
$all_tags = array();

foreach($all_tags as $key => $value){
 if(is_array($value) && count($value) > 0){
  foreach($value as $v2){
   if(!empty($v2)){
    $all_tags[] = $v2;
   }
  }
 }else{
  if(!empty($value)){
   $all_tags[] = $value;
  }
 }
}
在弦上没有“线”

希望有人能帮助:)

在之前添加此代码

echo';
$all_tags_copy=$all_tags;
$all_tags=array();
foreach($key=>$value的所有_标记){
if(is_数组($value)&&count($value)>0){
foreach(价值为$v2){
如果(!空($v2)){
$all_tags[]=$v2;
}
}
}否则{
如果(!空($value)){
$all_tags[]=$value;
}
}
}
在之前添加此代码

echo';
$all_tags_copy=$all_tags;
$all_tags=array();
foreach($key=>$value的所有_标记){
if(is_数组($value)&&count($value)>0){
foreach(价值为$v2){
如果(!空($v2)){
$all_tags[]=$v2;
}
}
}否则{
如果(!空($value)){
$all_tags[]=$value;
}
}
}

我没有测试,请测试并发布反馈我没有测试,请测试并发布反馈
Array
(
    [0] => Array
        (
            [tag_name] => Hej
        )

    [1] => Array
        (
            [tag_name] => Hvor
        )

    [2] => Array
        (
            [tag_name] => Hvad
        )

    [3] => 'wegehe'
    [4] => 'afqfq'
)
Array
    (
        [0] => Hej
        [1] => Hvor
        [2] => Hvad
        [3] => wegehe
        [4] => afqfq
    )
echo '<pre>';



$all_tags_copy = $all_tags;
$all_tags = array();

foreach($all_tags as $key => $value){
 if(is_array($value) && count($value) > 0){
  foreach($value as $v2){
   if(!empty($v2)){
    $all_tags[] = $v2;
   }
  }
 }else{
  if(!empty($value)){
   $all_tags[] = $value;
  }
 }
}