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