You are here: Re: Swapping array elements from two different arrays « PHP Programming Language « IT news, forums, messages
Re: Swapping array elements from two different arrays

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация