我有一个这样的数组
Array
(
[0] => Array
(
[ID] => 417
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 100
[ACTIVE] => Y
)
[1] => Array
(
[ID] => 418
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 200
[ACTIVE] => Y
)
[2] => Array
(
[ID] => 419
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 300
[ACTIVE] => Y
)
[3] => Array
(
[ID] => 420
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 400
[ACTIVE] => Y
)
[4] => Array
(
[ID] => 421
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 500
[ACTIVE] => Y
)
[5] => Array
(
[ID] => 422
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 600
[ACTIVE] => Y
)
[6] => Array
(
[ID] => 423
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 700
[ACTIVE] => Y
)
[7] => Array
(
[ID] => 424
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 800
[ACTIVE] => Y
)
[8] => Array
(
[ID] => 425
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 900
[ACTIVE] => Y
)
[9] => Array
(
[ID] => 426
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 1000
[ACTIVE] => Y
)
[10] => Array
(
[ID] => 427
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 1100
[ACTIVE] => Y
)
我想从它的每一行中获取一个表,其中应该有五个 [ID] 元素:
<tr>417 418 420 421 422</tr>
<tr>423 424 425 426 427</tr>
我这样做:
<?
$array = array_chunk($arResult["QUESTIONS"]["q18"]["STRUCTURE"], 5, true);
foreach ($array as $key => $arAnswer)
{
?>
<tr>
<?print_r ($arAnswer["ID"]);?>
</tr>
<?
} ?>
但这不是 ID 的显示方式,据我了解,因为首先您需要指定循环遍历数组的键
如果您在没有 ID 的情况下提款:
<?print_r ($arAnswer["ID"]);?>
这就是它给出的:
<tr>
Array
(
[0] => Array
(
[ID] => 164
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 100
[ACTIVE] => Y
)
[1] => Array
(
[ID] => 418
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 200
[ACTIVE] => Y
)
[2] => Array
(
[ID] => 419
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 300
[ACTIVE] => Y
)
[3] => Array
(
[ID] => 420
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 400
[ACTIVE] => Y
)
[4] => Array
(
[ID] => 421
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 500
[ACTIVE] => Y
)
)
</tr>
<tr>
Array
(
[5] => Array
(
[ID] => 422
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 600
[ACTIVE] => Y
)
[6] => Array
(
[ID] => 423
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 700
[ACTIVE] => Y
)
[7] => Array
(
[ID] => 424
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 800
[ACTIVE] => Y
)
[8] => Array
(
[ID] => 425
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 900
[ACTIVE] => Y
)
[9] => Array
(
[ID] => 426
[FIELD_ID] => 79
[QUESTION_ID] => 79
[TIMESTAMP_X] => 09.09.2022 15:10:04
[MESSAGE] =>
[VALUE] =>
[FIELD_TYPE] => text
[FIELD_WIDTH] => 0
[FIELD_HEIGHT] => 0
[FIELD_PARAM] =>
[C_SORT] => 1000
[ACTIVE] => Y
)
)
</tr>
也就是说,您需要以某种方式指定它将准确地从第一个数组的每个元素中获取 ID,但我不知道如何做到这一点,我试图在那里添加另一个循环,然后我更加困惑