I have associative arrays like this (stored in $array):
Array
(
[0] => Array
(
[one] => some text1
[two] => some paragraph here1.
)
[1] => Array
(
[one] => some text2
[two] => some paragraph here2.
)
[2] => Array
(
[one] => some text3
[two] => some paragraph here3.
)
[3] => Array
(
[one] => some text4
[two] => some paragraph here4.
)
[4] => Array
(
[one] => some text5
[two] => some paragraph here5.
)
)
Now, I want to store the result of them like this:
$first = 'some text1, some text2, some text3, some text4, some text5';
$second = 'some paragraph here1. some paragraph here2. some paragraph here3. some paragraph here4. some paragraph here5.';
Struggling a lot I got a solution like this:
$first= '';
$second = '';
for($i = 0; $i<count($array); $i++){
$first .= $array[$i]['one'] . ($i == count($array) - 1 ? '': ',');
$second .= $array[$i]['two'];
}
echo $first;
echo $second;
But I hope there's already a built-in php function which split assoc arrays into two different arrays.