Skip to content

Instantly share code, notes, and snippets.

@leewillis77
Created February 27, 2013 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leewillis77/5051740 to your computer and use it in GitHub Desktop.
Save leewillis77/5051740 to your computer and use it in GitHub Desktop.
<?php
$array_1 = array( 'apple', 'orange', 'bananna', 'grape' );
$array_2 = array(
'apple' => 'pear',
'grape' => 'pineapple',
);
$result = array();
foreach ( $array_1 as $test ) {
if ( isset ( $array_2[$test] ) )
$result[] = $array_2[$test];
else
$result[] = $test;
}
print_r($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment