array(12) {
  ["dictid1"]=>
  string(1) "1"
  ["sample1"]=>
  array(1) {
    [0]=>
    string(1) "1"
  }
  ["sample1_text"]=>
  string(24) "[email protected],"
  ["mailtrue1"]=>
  string(1) "0"
  ["dictid2"]=>
  string(1) "2"
  ["sample2"]=>
  array(1) {
    [0]=>
    string(2) "10"
  }
  ["sample2_text"]=>
  string(26) "[email protected],"
  ["mailtrue2"]=>
  string(1) "0"
  ["dictid3"]=>
  string(1) "3"
  ["sample3"]=>
  array(1) {
    [0]=>
    string(1) "9"
  }
  ["sample3_text"]=>
  string(21) "[email protected],"
  ["mailtrue3"]=>
  string(1) "0"
}结构中:dictid ~ mailtrue 为一个区间,,范例中包含三个区间,,区间数量不确定请问怎么拆分??结果想把每个区间拆分出来。。形成单独 区间格式。预期结果:array(4) {
  ["dictid1"]=>
  string(1) "1"
  ["sample1"]=>
  array(1) {
    [0]=>
    string(1) "1"
  }
  ["sample1_text"]=>
  string(24) "[email protected],"
  ["mailtrue1"]=>
  string(1) "0"
}
array(4) {
  ["dictid2"]=>
  string(1) "1"
  ["sample2"]=>
  array(1) {
    [0]=>
    string(1) "1"
  }
  ["sample2_text"]=>
  string(24) "[email protected],"
  ["mailtrue2"]=>
  string(1) "0"
}

解决方案 »

  1.   

    不喜欢VAR_DUMP,看不清楚
    喜欢 print_r
      

  2.   

    <?php
    $source = array(
    1=>"1",
    2=>"2",
    3=>"3",
    4=>"4",
    5=>"5",
    6=>"6",
    7=>"7",
    8=>"8"
    );$result = array_split_fixed_len($source,4);
    print_r($result);function array_split_fixed_len($in,$len){
    $batch = $offset = 0;

    foreach ($in as $key=>$val) {
    $result[$batch][$key] = $val;
    if (++$offset == $len) {
    $batch++;
    $offset = 0;
    }
    }
    return $result;
    }
    ?>
      

  3.   


    发问题用 var_export($source);