Link to home
Start Free TrialLog in
Avatar of ironlady
ironlady

asked on

need urgent help regarding arrays

hi all,
I have got 2 arrays @urls and @desp.  What I really wanna do is to combine these 2 arrays so that it give me urls and its own description like the first element of the combine array shud be http://www.city.surrey.bc.ac and second element shud be "city university website".



Similarly the third element of the combine array shud be surreycc.gov.uk and the 4th "surrey some description".

then i want to store the combined array in a hash array so that i get keys as website address and desp as value for it.

i have also tried using @combine=(@urls,@desp)
but iam not getting desired output.

@urls=("http://www.city.surrey.bc.ac",
 "http://www.surreycc.gov.uk/",
 "http://www.surreyweb.org.uk",
 "http://www.surreyad.co.uk/");
@desp=("city university website", "surrey some decsription", "surrey some description", "surrey");
@combine=();

foreach $item(@urls)
{
foreach $item2(@desp)
{
push(@combine,$item.$item2);
}
}


can anybody plz help as soon as possible.


thanks,
tie
ASKER CERTIFIED SOLUTION
Avatar of sykkn
sykkn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PC_User321
PC_User321

for ($i =0; $i <= $#urls; $i++) {
   $combine[$i * 2] = $urls[$i];
   $combine[$i * 2 +1] = $desp[$i];
}
Avatar of ironlady

ASKER

hi,

it seems both the codes are working thanks to pcuser and sykkn.

i wnat to split points between them so that they get 10 points each.

is that possible.

many thanks again for replying
tie
Of course you could be *really* nice for all their hard work, and give the full points to one of them, and then create another question - points for otherperson with the same number of points:)
thank u very much for ur help

kind regards
tie