Reputation: 324
I have 2 arrays
Array
(
[0] => company
[1] => companyid
)
Array
(
[company] => shops
)
And I want the first array to look like this.
Array
(
[0] => shops
[1] => companyid
)
I've tried alot of built in array functions but I couldn't get a grip on them.
Anyone has an idea?
Upvotes: 0
Views: 1511
Reputation: 14596
$data
is your first array, $replacement
is the second
foreach( $replacements as $key => $value ){
$data_key = array_search( $key, $data );
if( $data_key !== false ) $data[ $data_key ] = $value;
}
Upvotes: 1