[ create a new paste ] login | about

Link: http://codepad.org/NE9QwFS4    [ raw code | output | fork ]

PHP, pasted on Aug 21:
<?php

function doFor($data, $callback) {
    $dataLength = count($data);
    for ($i=0; $i<$dataLength; $i++) {
        call_user_func($callback, $data[$i]);
    }
    return $data;
}

///

$data = array(array("foo","bar"),array("hello"),array("world","!"));

function justDump($obj) {
    var_dump($obj);
};

$i = 0;
do {
    $data = doFor($data, 'justDump');
    print "\n";
    $i++;
} while($i<5);


Output:
array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
}
array(1) {
  [0]=>
  string(5) "hello"
}
array(2) {
  [0]=>
  string(5) "world"
  [1]=>
  string(1) "!"
}

array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
}
array(1) {
  [0]=>
  string(5) "hello"
}
array(2) {
  [0]=>
  string(5) "world"
  [1]=>
  string(1) "!"
}

array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
}
array(1) {
  [0]=>
  string(5) "hello"
}
array(2) {
  [0]=>
  string(5) "world"
  [1]=>
  string(1) "!"
}

array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
}
array(1) {
  [0]=>
  string(5) "hello"
}
array(2) {
  [0]=>
  string(5) "world"
  [1]=>
  string(1) "!"
}

array(2) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "bar"
}
array(1) {
  [0]=>
  string(5) "hello"
}
array(2) {
  [0]=>
  string(5) "world"
  [1]=>
  string(1) "!"
}



Create a new paste based on this one


Comments: