Jump to content

[SOLVED] Combining Arrays


davidz

Recommended Posts

I need to combine data from two arrays.  Specifically I need the values from one array and the keys from another combined where the keys are the same. 

Example:

[permissions] => Array
        (
            [ACPlatSearch] => 3
            [ACPropertySearch] => 11
            [ACActiveDwellings] => 12
            [ACUserInfo] => 13
            [ACStatsRecordedSubs] => 16
            [ACStats5yrTicker] => 17
            [ACStatsAbsorption] => 29
            [ACStatsTotalSales] => 28
            [ACStatsSalesProduct] => 27
            [ACStatsSalesDwellings] => 26
            [ACStatsSalesLots] => 25
        )

Plus:

Array
(
    [ACStatsSalesDwellings] => on
    [ACStatsRecordedSubs] => on
    [ACStats5yrTicker] => on
    [ACStatsActiveDwellings] => on
)

 

To end up like:

Array
(
    [ACStatsSalesDwellings] => 26
    [ACStatsRecordedSubs] => 16
    [ACStats5yrTicker] => 17
    [ACStatsActiveDwellings] => 12
)

 

Many thanks.

Link to comment
https://forums.phpfreaks.com/topic/56244-solved-combining-arrays/
Share on other sites

Wow, thanks for the super fast replies.

 

I've tried different iterations of array_merge, array_intersec, array_diff, etc.  But I can only get it to show something like:

Array
(
    [0] => ACStatsSalesDwellings
    [1] => ACStatsRecordedSubs
    [2] => ACStats5yrTicker
    [3] => ACStatsActiveDwellings
)

 

Or the exact opposite of that.  My next option is to do a foreach.  Any thoughts?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.