I have this array
$data = [
0 => [
'id' => '114',
'organization_name' => 'ABC Ltd',
'organization_telephone' => '01234 112233',
'organization_email' => 'admin@example.com',
'organization_url' => 'http://www.example.com',
'order_id' => '119',
'order_delivery_address_1' => '55',
'order_delivery_address_2' => 'High Street',
'order_delivery_address_3' => '',
'order_delivery_postcode' => 'LL27 0YX',
'product_colour_name' => 'Red',
'product_size_name' => '8/9',
'product_price' => '7.5',
'product_quantity' => '10',
'product_line_price' => '75',
],
];
And I want to divide it into 3 arrays as below:
$orgnization_details = [
'id' => '114',
'organization_name' => 'ABC Ltd',
'organization_telephone' => '01234 112233',
'organization_email' => 'admin@example.com',
'organization_url' => 'http://www.example.com',
]
$order_details = [
'order_id' => '119',
'order_delivery_address_1' => '55',
'order_delivery_address_2' => 'High Street',
'order_delivery_address_3' => '',
'order_delivery_postcode' => 'LL27 0YX',
]
$product_details = [
'product_colour_name' => 'Red',
'product_size_name' => '8/9',
'product_price' => '7.5',
'product_quantity' => '10',
'product_line_price' => '75',
]
I tried using array_filter
for orgnization_details as below
foreach ($data as $details)
{
$orgnization_details = array_filter($details, function($key) { return $key <= 'organization_url'; }, ARRAY_FILTER_USE_KEY);
}
But it didn't work as expected.
Please help me with this.