Skip to content

Instantly share code, notes, and snippets.

@nellytadi
Last active November 27, 2019 10:39
Show Gist options
  • Save nellytadi/77ca6fe33490f7198c4e9db80f769817 to your computer and use it in GitHub Desktop.
Save nellytadi/77ca6fe33490f7198c4e9db80f769817 to your computer and use it in GitHub Desktop.
Merge two array and give them new keys
<?php
public function test(){
$array =[0=> [ "organisation_name" => "HERTFORDSHIRE LIMITED",
"company_number" => "06124924",
"address" => " Schopwick Place, High Street, Elstree, Hertfordshire, England, WD6 3SW",
"company_status" => "active",
"company_type" => "ltd",
"date_of_incorporation" => "2007-02-23",
"nature_of_business" => "70100",
"town" => "Elstree"]];
$array2=[1=>[
"organisation_name" => "ACACIAS CONSULTING LTD",
"company_number" => "10715824",
"address" => " 2 Claridge Court, Lower Kings Road, Berkhamsted, United Kingdom, HP4 2AF",
"company_status" => "active",
"company_type" => "ltd",
"date_of_incorporation" => "2017-04-07",
"nature_of_business" => "70229",
"town" => "Berkhamsted"
]];
$merge = array_merge($array,$array2);
dd($merge);
}
@nellytadi
Copy link
Author

Had to give them keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment