Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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 用另一个数组为数组设置关键帧?_Php_Arrays - Fatal编程技术网

Php 用另一个数组为数组设置关键帧?

Php 用另一个数组为数组设置关键帧?,php,arrays,Php,Arrays,我在下面有一个数组: "checkbox_1": [ "1" ], "checkbox_2": [ "0" ], "checkbox_3": [ "0" ], "checkbox_4": [ "0" ], "checkbox_5": [ "0" ], "checkbox_6": [ "0" ], "checkbox_7":

我在下面有一个数组:

    "checkbox_1": [
      "1"
    ],
    "checkbox_2": [
      "0"
    ],
    "checkbox_3": [
      "0"
    ],
    "checkbox_4": [
      "0"
    ],
    "checkbox_5": [
      "0"
    ],
    "checkbox_6": [
      "0"
    ],
    "checkbox_7": [
      "0"
    ],
    "checkbox_8": [
      "0"
    ]
我想知道使成对阵列有效存储标签的最佳方法:

$checkboxes = array('text value', 'text value, 'text value', '..');
如果复选框_1为1,则查找文本值并输出


我试过一种方法,但觉得有一种很好的方法

array\u intersect\u键可以帮助您。我看起来很干净

$c = [
    'a'=>1,
    'b'=>0,
    'c'=>1,
    'd'=>0,
    'e'=>0,
    'f'=>1
];

$d = [
    'asd1',
    'asd2',
    'asd3',
    'asd4',
    'asd5',
    'asd6'
];

print_r(array_intersect_key($d, array_filter(array_values($c))));
结果

Array
(
    [0] => asd1
    [2] => asd3
    [5] => asd6
)

让我们检查
数组映射
数组漫游
函数。您可能错过了一个引号。最好让JavaScript将复选框作为数组提交,即
[1,0,0,0,0,…]