Home  >  Q&A  >  body text

How can two two-dimensional arrays be combined into one array, with one as a key and the other as a value? ? ?

Array 1:

$devicename = array(

      array('t0001'),

      array('t0002'),

Array('t0003'),

);

Array 2:

$arrstatus = array(

                                                                                                                        use using using                 ‐ ’ s ’ s ‐ ‐ ‐ ‐ ‐ 'status' => '1',

##                 'online_status' =>'1',

                                                               Array (

'STATUS' = & GT; '1',

## 'Online_status' = & GT

'STATUS' = & GT; '1',

## 'ONLINE_STAS' = & GT; '1',

#),

); ##)

# The method of merging one-dimensional arrays found online (but it cannot be used)

$savearrays = array_combine($devicename,$arrstatus);

var_dump($savearrays);die;

The final desired effect is:

array (size=3)
't0001' =>

array (size=2)

'status' => string '1' (length=1)

'online_status' => string '1' (length =1)

't0002' =>

array (size=2)

'status' => string '1' (length=1)
'online_status' => string ' 1' (length=1)

't0003' =>

array (size=2) 'status' => string '1' (length=1) 'online_status' = > string '1' (length=1)

myfeymyfey2537 days ago1737

reply all(1)I'll reply

  • myfey

    myfey2017-12-01 11:09:32

    How do you combine two two-dimensional arrays, one of which serves as a key and the other as a value, into one array? ? ?

    reply
    0
  • Cancelreply