3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sweet = array('a' => 'apple', 'b' => 'banana'); $fruits = array('sweet' => $sweet, 'sour' => 'lemon'); $arr = array('data-object.url' => 'http://yamamotohi.beautist.dev-php55.istyle.local/beautist/article/2004580', 'data-object.parent.class' => 'blog', 'data-object.parent.id' => '2004580', 'data-object.parent.owner.class' =>'uid', 'data-object.parent.owner.id' => '101607419', ); function test_print($item, $key) { echo "$key holds $item\n"; } array_walk_recursive($fruits, 'test_print'); array_walk_recursive($arr, function($item, $key){ echo "$key=\"$item\"\n"; }); $str = ''; array_walk_recursive($arr, function($item, $key){ $str .= vsprintf("$key=\"$item\"\n"); }); var_dump($str); ?>
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
a holds apple b holds banana sour holds lemon data-object.url="http://yamamotohi.beautist.dev-php55.istyle.local/beautist/article/2004580" data-object.parent.class="blog" data-object.parent.id="2004580" data-object.parent.owner.class="uid" data-object.parent.owner.id="101607419" Fatal error: Uncaught ArgumentCountError: vsprintf() expects exactly 2 arguments, 1 given in /in/kq5W1:26 Stack trace: #0 /in/kq5W1(26): vsprintf('data-object.url...') #1 [internal function]: {closure}('http://yamamoto...', 'data-object.url') #2 /in/kq5W1(25): array_walk_recursive(Array, Object(Closure)) #3 {main} thrown in /in/kq5W1 on line 26
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 a holds apple b holds banana sour holds lemon data-object.url="http://yamamotohi.beautist.dev-php55.istyle.local/beautist/article/2004580" data-object.parent.class="blog" data-object.parent.id="2004580" data-object.parent.owner.class="uid" data-object.parent.owner.id="101607419" Fatal error: Uncaught ArgumentCountError: vsprintf() expects exactly 2 arguments, 1 given in /in/kq5W1:26 Stack trace: #0 /in/kq5W1(26): vsprintf('data-object.url...') #1 [internal function]: {closure}('http://yamamoto...', 'data-object.url') #2 /in/kq5W1(25): array_walk_recursive(Array, Object(Closure)) #3 {main} thrown in /in/kq5W1 on line 26
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
a holds apple b holds banana sour holds lemon data-object.url="http://yamamotohi.beautist.dev-php55.istyle.local/beautist/article/2004580" data-object.parent.class="blog" data-object.parent.id="2004580" data-object.parent.owner.class="uid" data-object.parent.owner.id="101607419" Fatal error: Uncaught ArgumentCountError: vsprintf() expects exactly 2 arguments, 1 given in /in/kq5W1:26 Stack trace: #0 /in/kq5W1(26): vsprintf('data-object.url...') #1 [internal function]: {closure}('http://yamamoto...', 'data-object.url') #2 /in/kq5W1(27): array_walk_recursive(Array, Object(Closure)) #3 {main} thrown in /in/kq5W1 on line 26
Process exited with code 255.
Output for 7.4.0 - 7.4.33
a holds apple b holds banana sour holds lemon data-object.url="http://yamamotohi.beautist.dev-php55.istyle.local/beautist/article/2004580" data-object.parent.class="blog" data-object.parent.id="2004580" data-object.parent.owner.class="uid" data-object.parent.owner.id="101607419" Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 string(0) ""
Output for 7.3.32 - 7.3.33
a holds apple b holds banana sour holds lemon data-object.url="http://yamamotohi.beautist.dev-php55.istyle.local/beautist/article/2004580" data-object.parent.class="blog" data-object.parent.id="2004580" data-object.parent.owner.class="uid" data-object.parent.owner.id="101607419" Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 string(0) ""
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31
a holds apple b holds banana sour holds lemon data-object.url="http://yamamotohi.beautist.dev-php55.istyle.local/beautist/article/2004580" data-object.parent.class="blog" data-object.parent.id="2004580" data-object.parent.owner.class="uid" data-object.parent.owner.id="101607419" Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 Warning: Wrong parameter count for vsprintf() in /in/kq5W1 on line 26 Notice: Undefined variable: str in /in/kq5W1 on line 26 string(0) ""

preferences:
190.15 ms | 404 KiB | 167 Q