@ 2013-03-14T10:20:46Z <?php
$array = array(
'val1', 'val2', 'val3', 'val4', 'val5',
);
print_out( $array );
array_walk( $array, function( &$value, $key ) use( &$array ){
$array[ $value ] = array(
'rule' => 'ctype_alnum',
);
unset( $array[ $key ] );
});
function print_out( $val )
{
echo '<pre>';
var_dump( $val );
echo '</pre>';
}
print_out( $array );
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.3.0 - 8.3.6 <pre>array(5) {
[0]=>
string(4) "val1"
[1]=>
string(4) "val2"
[2]=>
string(4) "val3"
[3]=>
string(4) "val4"
[4]=>
string(4) "val5"
}
</pre>
Fatal error: Uncaught TypeError: Cannot access offset of type array on array in /in/iBhQB:10
Stack trace:
#0 [internal function]: {closure}(Array, 'val1')
#1 /in/iBhQB(9): array_walk(Array, Object(Closure))
#2 {main}
thrown in /in/iBhQB on line 10
Process exited with code 255 . Output for 8.2.0 - 8.2.18 <pre>array(5) {
[0]=>
string(4) "val1"
[1]=>
string(4) "val2"
[2]=>
string(4) "val3"
[3]=>
string(4) "val4"
[4]=>
string(4) "val5"
}
</pre>
Fatal error: Uncaught TypeError: Illegal offset type in /in/iBhQB:10
Stack trace:
#0 [internal function]: {closure}(Array, 'val1')
#1 /in/iBhQB(9): array_walk(Array, Object(Closure))
#2 {main}
thrown in /in/iBhQB on line 10
Process exited with code 255 . Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 <pre>array(5) {
[0]=>
string(4) "val1"
[1]=>
string(4) "val2"
[2]=>
string(4) "val3"
[3]=>
string(4) "val4"
[4]=>
string(4) "val5"
}
</pre>
Fatal error: Uncaught TypeError: Illegal offset type in /in/iBhQB:10
Stack trace:
#0 [internal function]: {closure}(Array, 'val1')
#1 /in/iBhQB(14): array_walk(Array, Object(Closure))
#2 {main}
thrown in /in/iBhQB on line 10
Process exited with code 255 . Output for 5.3.0 - 5.3.13 , 5.4.0 - 5.4.3 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 <pre>array(5) {
[0]=>
string(4) "val1"
[1]=>
string(4) "val2"
[2]=>
string(4) "val3"
[3]=>
string(4) "val4"
[4]=>
string(4) "val5"
}
</pre>
Warning: Illegal offset type in /in/iBhQB on line 10
Warning: Illegal offset type in /in/iBhQB on line 10
Warning: Illegal offset type in /in/iBhQB on line 10
Warning: Illegal offset type in /in/iBhQB on line 10
Warning: Illegal offset type in /in/iBhQB on line 10
<pre>array(0) {
}
</pre> Output for 7.0.0 - 7.0.33 <pre>array(5) {
[0]=>
string(4) "val1"
[1]=>
string(4) "val2"
[2]=>
string(4) "val3"
[3]=>
string(4) "val4"
[4]=>
string(4) "val5"
}
</pre>Process exited with code 139 . Output for 5.3.14 - 5.3.29 , 5.4.4 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.38 <pre>array(5) {
[0]=>
string(4) "val1"
[1]=>
string(4) "val2"
[2]=>
string(4) "val3"
[3]=>
string(4) "val4"
[4]=>
string(4) "val5"
}
</pre>
Warning: Illegal offset type in /in/iBhQB on line 10
<pre>array(4) {
[1]=>
string(4) "val2"
[3]=>
string(4) "val4"
["val1"]=>
array(1) {
["rule"]=>
string(11) "ctype_alnum"
}
["val5"]=>
array(1) {
["rule"]=>
string(11) "ctype_alnum"
}
}
</pre> Output for 4.4.2 - 4.4.9 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 Parse error: syntax error, unexpected T_FUNCTION in /in/iBhQB on line 9
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 , 5.0.0 - 5.0.5 Parse error: parse error, unexpected T_FUNCTION in /in/iBhQB on line 9
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/iBhQB on line 9
Process exited with code 255 . preferences:dark mode live preview
330.22 ms | 401 KiB | 454 Q