I'm quite new to PHP and coming from a Java background. So here it goes:
I have this code:
$selected = array();
foreach($this->getSelectedOptions() AS $array) {
array_push($selected, $array['value']);
}
var_dump($selected);
getSelectedOptions() retrieves an array of arrays containing strings.
The result is
array
0 => string 'abc, def' (length=31)
I was expecting something like this though:
Array
(
[0] => abc
[1] => def
)
Why is this happening? How can I make my array look like the latter (without doing any post-processing with commas etc.)
Thanks!
$array['value']
isn't actually an array (is this coming from a database?). You may need toexplode(',', $array['value']);
. – Rocket Hazmat May 14 '12 at 17:53var_dump($this->getSelectedOptions())
? – bitoshi.n May 14 '12 at 17:56