fork(57) download
  1. <?php
  2.  
  3. $array = array(
  4. array('1', '0', '1'),
  5. array('0', '0', '0'),
  6. array('1', '0', '1'),
  7. );
  8.  
  9. function delete_row(&$array, $offset) {
  10. return array_splice($array, $offset, 1);
  11. }
  12.  
  13. function delete_col(&$array, $offset) {
  14. return array_walk($array, function (&$v) use ($offset) {
  15. array_splice($v, $offset, 1);
  16. });
  17. }
  18.  
  19. print_r($array);
  20.  
  21. delete_row($array, 1);
  22. delete_col($array, 1);
  23.  
  24. print_r($array);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => 1
            [1] => 0
            [2] => 1
        )

    [1] => Array
        (
            [0] => 0
            [1] => 0
            [2] => 0
        )

    [2] => Array
        (
            [0] => 1
            [1] => 0
            [2] => 1
        )

)
Array
(
    [0] => Array
        (
            [0] => 1
            [1] => 1
        )

    [1] => Array
        (
            [0] => 1
            [1] => 1
        )

)