【发布时间】:2011-08-03 18:40:30
【问题描述】:
我在查找代码时遇到了麻烦:
我有这个数组:
$filtros['code'] = 1
$filtros['name'] = 'John'
$filtros['formacion_c_1'] = 2
$filtros['formacion_c_2'] = 1
$filtros['formacion_c_3'] = 2
我需要捕捉每个“formacion_c_{number}”的数量和他的价值
echo "The Formation number {number} has the value $filtros[formacion_c_{number}]";
我需要的结果是这样的:
The Formation number 1 has the value 2.
The Formation number 2 has the value 1.
The Formation number 3 has the value 2.
当然解决方案是使用一些 preg_split 或 preg_match,但我无法处理这个
【问题讨论】:
-
你是从别人那里得到这个数组还是你自己定义的?如果是后者,为什么不使用二维数组?
-
我从表单中得到这个数组
-
@grteibo:表单可以向您发送数组。
<input name="formacion_c[]" />。那么$_POST['formacion_c']将是一个数组。 -
是的,但这在 Zend_Form_Elements 中是不可能的,谢谢