This question already has an answer here:
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
There will be array_column function is PHP 5.5, you will be able to do this
For now you have to use your own loop
So what's wrong with using a loop ?
If you're using PHP 5.3+: