php/e13array.php

<?php

require_once('env.php');
outBegin('Array');

$c = [['a', 'b'], ['c', 'd']];
outEC("c", $c);
$c[0][0] = [['q', 'r'], ['s', 't']];
out("c = ", a2str($c, -5));


outH('$a[] = highest natural key + 1, array_pop: last added');
$a = ['null' => 'nullChar', 'eins' => 1];
outEC('a orig', $a);
$a[] = 'added->1';
outEC('a1 ...', $a, 'pop', array_pop($a));
$a[-2] = '-2->2';
$a[] = 'added->3';
outEC('a3 -2 .', $a, 'pop', array_pop($a));
$a[4] = '+4->4';
$a[] = 'added->5';
$a['sechs'] = 'sechs->6';
outEC('a6 +4 .', $a, 'pop', array_pop($a), 'pop', array_pop($a));

outH('internal iterator');
$b = ['zero', true => 'one', 'zwei' => 'two', 'drei' => 'three'];
outOL('array b', $b);
outLi('current =', current($b));
outLi('next =', next($b));
outLi('end =', end($b));
outLi('prev =', prev($b));
outLi('end =', end($b));
outLi('next =', next($b));
outLi('current =', current($b));
outLi('prev =', prev($b));
outLi('next =', next($b));
outLi('reset =', reset($b));
outLi('current =', current($b));
outLi('each =', each($b));
outLi('each =', each($b));
$c=$b;
reset($c);
outLi('after reset$c=$b; reset($c) ==> internal pointer is normal data: copyOnWrite separates the array');
outLi('next($b)', next($b));
outLi('next($c)', next($c));
outLi('next($b)', next($b));
outLi('next($c)', next($c));

outOLend();
outEnd(__file__);
?>