标签: php
在具有相同ID的动态字段中计算php:
[item_sequence_0] => 1 [item_sequence_1] => 2
需要计算项目顺序:
即。 $a = count($data[item_sequence]);
$a = count($data[item_sequence]);
显示所需的结果:
$a = 2
答案 0 :(得分:6)
$a = count(preg_grep('~^item_sequence~', array_keys($data)));