Is there any way I can explode the array values of a big array without iterating through each item?
For e.g. I have
$Array = [
'Foo and Bar',
'Bar and Baz',
'Baz and Foo'
];
I want
$Array1 = [
'Foo',
'Bar',
'Baz'
];
$Array2 = [
'Bar',
'Baz',
'Foo'
];
I can achieve this by simply doing a foreach
loop. Like this
foreach ($Array as $Value) {
$DataEx = explode(' and ', $Value);
$Array1[] = $DataEx[0];
$Array2[] = $DataEx[1];
}
I have came across answers where some iteration is being suggested. But I seek to know if it can be achieved by any array function of PHP or by any combination of such array functions.