How to combine two arrays of same length to one array with two fields (not append/merge)

Posted by Raj on Stack Overflow See other posts from Stack Overflow or by Raj
Published on 2010-05-20T21:30:50Z Indexed on 2010/05/20 21:40 UTC
Read the original article Hit count: 184

Say, I have an array with months

$months = array('Jan', 'Feb', 'Mar'...'Dec');

And another, with days (say, for year 2010)

$mdays = array(31, 28, 31...31);

I want to merge/combine these two arrays, into an array like this:

$monthdetails[0] = ('month' => 'Jan', 'days' => 31)

$monthdetails[1] = ('month' => 'Feb', 'days' => 28)

...

$monthdetails[11] = ('month' => 'Dec', 'days' => 31)

I can loop through both the arrays and fill the $monthdetails. I want to know whether there are any functions/easier way for achieving the same result.

Thanks! Raj

© Stack Overflow or respective owner

Related posts about php

Related posts about array