2017-06-28 16 views
1

私は自分のプロジェクトでjsonを取得してから、サブ配列の一部を置き換えて再度渡す必要があります。ですから、jsonをデコードしてpreタグで表示すると、このような表示になります。サブ配列の置き換え方法

Array 
(
[callid] => 59538ea658dfa 
[action] => config_get 
[message] => ok 
[data] => Array 
    (
     [config_file] => /cf/conf/config.xml 
     [config] => Array 
      (
       [filter] => Array 
        (
         [separator] => Array 
          (
           [wan] => 
          ) 

         [rule] => Array 
          (
           [0] => Array 
            (
             [id] => 
             [tracker] => 1498479412 
             [type] => pass 
             [interface] => wan 
             [ipprotocol] => inet 
             [tag] => 
             [tagged] => 
             [max] => 
             [max-src-nodes] => 
             [max-src-conn] => 
             [max-src-states] => 
             [statetimeout] => 
             [statetype] => keep state 
             [os] => 
             [protocol] => tcp 
             [source] => Array 
              (
               [any] => 
              ) 

             [destination] => Array 
              (
               [any] => 
              ) 

             [descr] => Hi manoj2 
             [updated] => Array 
              (
               [time] => 1498479412 
               [username] => [email protected] 
              ) 

             [created] => Array 
              (
               [time] => 1498479412 
               [username] => [email protected] 
              ) 

            ) 

           [1] => Array 
            (
             [statetype] => keep state 
             [statetimeout] => 
             [max-src-states] => 
             [max] => 
             [tagged] => 
             [tag] => 
             [ipprotocol] => inet 
             [interface] => wan 
             [os] => 
             [source] => Array 
              (
               [any] => 
              ) 

             [destination] => Array 
              (
               [any] => 
              ) 

             [descr] => hi Divyesh 
             [updated] => Array 
              (
               [username] => [email protected] 
               [time] => 1498301528 
              ) 

             [created] => Array 
              (
               [username] => [email protected] 
               [time] => 1498301528 
              ) 

             [type] => pass 
             [tracker] => 1498301528 
             [id] => 
             [max-src-nodes] => 
             [max-src-conn] => 
            ) 

           [2] => Array 
            (
             [destination] => Array 
              (
               [any] => 
              ) 

             [source] => Array 
              (
               [network] => lan 
              ) 

             [tracker] => 0100000101 
             [interface] => lan 
             [descr] => Default allow LAN to any rule 
             [ipprotocol] => inet 
             [type] => pass 
            ) 

           [3] => Array 
            (
             [destination] => Array 
              (
               [any] => 
              ) 

             [source] => Array 
              (
               [network] => lan 
              ) 

             [tracker] => 0100000102 
             [interface] => lan 
             [descr] => Default allow LAN IPv6 to any rule 
             [ipprotocol] => inet6 
             [type] => pass 
            ) 

          ) 

        ) 

       [shaper] => 
       [ipsec] => 
       [aliases] => Array 
        (
         [alias] => Array 
          (
           [0] => Array 
            (
             [name] => manoj2_alias2 
             [type] => network 
             [address] => manoj2_alias3 172.30.2.65/16 172.30.2.51/32 
             [descr] => descc 
             [detail] => nfvbg||dfg||asd | asdfg 
            ) 

           [1] => Array 
            (
             [name] => manoj2_alias3 
             [type] => host 
             [address] => tyuty tyu 
             [descr] => dess 
             [detail] => tyu||tyu 
            ) 

           [2] => Array 
            (
             [name] => sdf 
             [type] => network 
             [address] => manoj2_alias2 
             [descr] => afsasf || weriojdg 
             [detail] => 256418 
            ) 

          ) 

        ) 

      ) 

    ) 

と私はちょうど[ルール]の部分サブアレイとを交換したいです。

[rule] => Array 
          (
           [0] => Array 
            (
             [id] => 
             [tracker] => 1498479412 
             [type] => block 
             [interface] => lan 
             [ipprotocol] => any 
             [tag] => 
             [tagged] => 
             [max] => 
             [max-src-nodes] => 
             [max-src-conn] => 
             [max-src-states] => 
             [statetimeout] => 
             [statetype] => keep state 
             [os] => 
             [protocol] => tcp/udp 
             [source] => Array 
              (
               [any] => 
              ) 

             [destination] => Array 
              (
               [any] => 
              ) 

             [descr] => second option 
             [updated] => Array 
              (
               [time] => 149844356 
               [username] => [email protected] 
              ) 

             [created] => Array 
              (
               [time] => 1498479412 
               [username] => [email protected] 
              ) 

            ) 

           [1] => Array 
            (
             [statetype] => keep state 
             [statetimeout] => 
             [max-src-states] => 
             [max] => 
             [tagged] => 
             [tag] => 
             [ipprotocol] => single 
             [interface] => wan 
             [os] => 
             [source] => Array 
              (
               [any] => 172.31.2.65/24 
              ) 

             [destination] => Array 
              (
               [any] => manoj2_alias2 
              ) 

             [descr] => first option 
             [updated] => Array 
              (
               [username] => [email protected] 
               [time] => 1498301528 
              ) 

             [created] => Array 
              (
               [username] => [email protected] 
               [time] => 1498301528 
              ) 

             [type] => pass 
             [tracker] => 1498301528 
             [id] => 
             [max-src-nodes] => 
             [max-src-conn] => 
            ) 

          ) 

どうすればいいですか?私は何もしなかった。

答えて

0

配列要素にアクセスし、新しい配列を割り当てます。

$array['data']['config']['filter']['rule'] = $theNewRuleArray; 
+0

'$ theNewRuleArray()' ??? – AbraCadaver

関連する問題