Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Array Help

Question posted by: Damodhar (Guest) on March 14th, 2008 04:45 PM
HI any one help me to solve the solution



one array having the values like

$array1 = array(1,2,3,4);

$array2 = array(A,B,C,D);


i want to create the new array array using the array1 and array2

like :
$ans = array(1,A,2,B,3,C,4,D)


how can i create the new array is there any predefined functions or
any ???
Alred Wallace's Avatar
Alred Wallace
Guest
n/a Posts
March 14th, 2008
05:15 PM
#2

Re: Array Help

"Damodhar" <damu.be@gmail.coma écrit dans le message de news:
Join Bytes!...
Quote:
HI any one help me to solve the solution
>
>
>
one array having the values like
>
$array1 = array(1,2,3,4);
>
$array2 = array(A,B,C,D);
>
>
i want to create the new array array using the array1 and array2
>
like :
$ans = array(1,A,2,B,3,C,4,D)
>
>
how can i create the new array is there any predefined functions or
any ???



$newArray = array();
for( $i=0;$i<count( $array1 ); $i++ ){
$newArray[] = array1[$i];
$newArray[] = array2[$i];
}



Guillaume's Avatar
Guillaume
Guest
n/a Posts
March 14th, 2008
05:15 PM
#3

Re: Array Help
Damodhar a écrit :
Quote:
one array having the values like
>
$array1 = array(1,2,3,4);
>
$array2 = array(A,B,C,D);
>
>
i want to create the new array array using the array1 and array2
>
like :
$ans = array(1,A,2,B,3,C,4,D)


http://www.php.net/array_merge

Regards,
--
Guillaume

Damodhar's Avatar
Damodhar
Guest
n/a Posts
March 14th, 2008
10:15 PM
#4

Re: Array Help
hi Alred Wallace,

thanks for your code wonderful,


 
Not the answer you were looking for? Post your question . . .
189,919 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors