Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Join

Posted on 2000-04-23
3
Medium Priority
?
177 Views
Last Modified: 2010-03-05
I have 2 arrays, with the following data:

Array1
rr
ff
dd
ee

Array2
11
22
33
44

I actually is thinking of using 'join' to join the 2 array together, but like the following:
rr 11 ff 22 dd 33 ee 44

Is it possible?

Thanks
0
Comment
Question by:sata
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
adam923 earned 400 total points
ID: 2742149
join puts one constant item in between each element
you want an "interleave" like this...

@a1 = ('rr', 'ff', 'dd', 'ee');
@a2 = ('11', '22', '33', '44');
@a3 = ();
for($i=0; $i<$#a1; $i++){
   push @a3, $a1[$i], $a2[$i];
}
0
 
LVL 4

Expert Comment

by:adam923
ID: 2742151
sorry... change the
$i<$#a1
to
$i<=$#a1
0
 
LVL 84

Expert Comment

by:ozo
ID: 2742553
@a3 = map{$_,shift @a2} @a1;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question