本文介绍了多维数组内爆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我正在处理的多维数组的示例格式:
数组 ([1] =>数组 ( [code] => PPJ3 [street] => 34412 Fake Street [city] => Detroit [state] => MI [zip] => 48223 [county] => Wayne [cost] => 432.00 )[2] =>数组 ( [code] => PLK3 [street] => 73517 Fake Street [city] => Detroit [state] => MI [zip] => 48223 [county] => Wayne [cost] => 54.00 )[3] =>Array ( [code] => HYK2 [street] => 55224 Fake Street [city] => Detroit [state] => MI [zip] => 48208 [county] => Wayne [cost] => 345.00 ))
我试图将隐藏字段设置为仅代码值并用逗号分隔.数组也需要循环,因为它总是会改变.这是我想要的样子:
$myHiddenField = PPJ3、PLK3、HYK2
有什么简单的编码方法?
解决方案
只要能引用原数组即可..
或用于 csv
Here is an example format of the multidimensional array I'm dealing with:
Array (
[1] => Array ( [code] => PPJ3 [street] => 34412 Fake Street [city] => Detroit [state] => MI [zip] => 48223 [county] => Wayne [cost] => 432.00 )
[2] => Array ( [code] => PLK3 [street] => 73517 Fake Street [city] => Detroit [state] => MI [zip] => 48223 [county] => Wayne [cost] => 54.00 )
[3] => Array ( [code] => HYK2 [street] => 55224 Fake Street [city] => Detroit [state] => MI [zip] => 48208 [county] => Wayne [cost] => 345.00 )
)
I am trying to set a hidden field to only the code values and have it comma separated. The array would also need to be looped through because it will always change.This is what I would like for it to look like:
$myHiddenField = PPJ3, PLK3, HYK2
What is a simple way of coding this?
解决方案
as long as you can reference the original array ..
or for a csv
这篇关于多维数组内爆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!