fork download
  1. <?php
  2.  
  3. $arr = array
  4. (
  5. "CodeConfiguration" => array
  6. (
  7. (
  8. "ObjectType" => 12,
  9. "LineNo" => 1,
  10. "CompanyID" => 1,
  11. "BranchID" => 46,
  12. "ModifiedDate" => "2014-04-25 05:10:15",
  13. "RevisionNumber" => 6,
  14. "IsDirty" => "123"
  15. )
  16. ),
  17. "TaxConfiguration" => array
  18. (
  19. (
  20. "LineNo" => 2,
  21. "IsDirty" => 1,
  22. "ItemGroupID" => "",
  23. "TaxID" => "",
  24. "CalculationType_080" => 430,
  25. "RevisionNumber" => 1
  26. ),
  27.  
  28. (
  29. "LineNo" => 1,
  30. "IsDirty" => 1,
  31. "ItemGroupID" =>"",
  32. "TaxID" => "",
  33. "CalculationType_080" => 372,
  34. "RevisionNumber" => 1
  35. )
  36. )
  37. );
  38.  
  39. $finalArr = array();
  40.  
  41. foreach ($arr as $key => $item) {
  42. foreach ($item as $k => $v) {
  43. $finalArr[$key][] = array(
  44. "LineNo" => $v["LineNo"],
  45. "IsDirty" => $v["IsDirty"]
  46. );
  47. }
  48. }
  49.  
  50. var_dump($finalArr);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(2) {
  ["CodeConfiguration"]=>
  array(1) {
    [0]=>
    array(2) {
      ["LineNo"]=>
      int(1)
      ["IsDirty"]=>
      string(3) "123"
    }
  }
  ["TaxConfiguration"]=>
  array(2) {
    [0]=>
    array(2) {
      ["LineNo"]=>
      int(2)
      ["IsDirty"]=>
      int(1)
    }
    [1]=>
    array(2) {
      ["LineNo"]=>
      int(1)
      ["IsDirty"]=>
      int(1)
    }
  }
}