3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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); ?>
based on 9ubAM
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
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) ""
Output for hhvm-3.15.4
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 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 Warning: vsprintf() expects exactly 2 parameters, 1 given in /in/kq5W1 on line 26 string(0) ""