|
Posted by badar.waqas@gmail.com on 11/10/07 11:18
On Nov 10, 3:28 pm, Chris <matchett...@googlemail.com> wrote:
> How would I replace the elements with matching keys between $array1
> and $array2 to end up with 'a,b,c,d,e,f'.
>
> $array1 - Array ( [2] => c [3] => d )
>
> $array2 - Array ( [0] => a [1] => b [2] => x [3] => x [4] => e [5] =>
> f )
>
> Many thanks,
>
> Chris
you can use this code
foreach($array1 as $key => $value)
{
if(array_key_exists($key, $array2))
{
$array2[$key] = $value;
}
}
Navigation:
[Reply to this message]
|