summaryrefslogtreecommitdiff
path: root/ext/ffi/tests/026.phpt
blob: 1c5081c188b07fe08c38e39cf9df70bdc71243fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--TEST--
FFI 026: Array iteration by reference
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--INI--
ffi.enable=1
--FILE--
<?php
$a = FFI::new("int[3]");
$a[1] = 10;
$a[2] = 20;
var_dump($a);
foreach ($a as &$val) {
    $val->cdata += 5;
}
var_dump($a);
?>
--EXPECTF--
object(FFI\CData:int32_t[3])#%d (3) {
  [0]=>
  int(0)
  [1]=>
  int(10)
  [2]=>
  int(20)
}
object(FFI\CData:int32_t[3])#%d (3) {
  [0]=>
  int(5)
  [1]=>
  int(15)
  [2]=>
  int(25)
}