3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // 元データを用意する $a = array(); $a[2]=10; $a[10]=2; $a[3]=30; $a[22]=20; $a[9]=4; $a[53]=29; //確認 echo $a; //キーを保持してソート asort($a); //確認 echo $a; //最初から 3 個を $b[] に代入 $i = 0; $b = array(); foreach ($a as $k=>$d){ $b[] = $k; if (3 <= ++$i){ break;} } //確認 echo ($b); ?>
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Array to string conversion in /in/9G0bU on line 11 Array Notice: Array to string conversion in /in/9G0bU on line 15 Array Notice: Array to string conversion in /in/9G0bU on line 24 Array
Output for 4.3.0 - 5.3.29
ArrayArrayArray