3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array(1,1,1,2,2,3,3,1,1,2,2,3); $result = array(); $prev_value = array('value' => null, 'amount' => null); foreach ($arr as $val) { if ($prev_value['value'] != $val) { unset($prev_value); $prev_value = array('value' => $val, 'amount' => 0); $result[] =& $prev_value; } $prev_value['amount']++; } echo ($result);
Output for 5.4.0 - 7.1.0
Notice: Array to string conversion in /in/Nu9um on line 17 Array
Output for 4.3.0 - 5.3.29
Array