3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = $array2 = array("Fairy Tail - Ending 19v2 [Lenny]", "Fairy Tail - Ending 19v3 [Kagura]", "Fairy Tail - Ending 19v4 [Mio]", "Fairy Tail - Ending 19v1 [Erza]"); natsort($array); var_dump($array); usort($array2, function($a, $b) { return ($a['days'] > $b['days']) ? 1 : ($a['days'] < $b['days']) ? -1 : 0; }); var_dump($array2);
based on b9tUj
Output for 7.0.0 - 7.2.0
array(4) { [3]=> string(31) "Fairy Tail - Ending 19v1 [Erza]" [0]=> string(32) "Fairy Tail - Ending 19v2 [Lenny]" [1]=> string(33) "Fairy Tail - Ending 19v3 [Kagura]" [2]=> string(30) "Fairy Tail - Ending 19v4 [Mio]" } Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 array(4) { [0]=> string(32) "Fairy Tail - Ending 19v2 [Lenny]" [1]=> string(33) "Fairy Tail - Ending 19v3 [Kagura]" [2]=> string(30) "Fairy Tail - Ending 19v4 [Mio]" [3]=> string(31) "Fairy Tail - Ending 19v1 [Erza]" }
Output for 5.4.2 - 5.6.28
array(4) { [3]=> string(31) "Fairy Tail - Ending 19v1 [Erza]" [0]=> string(32) "Fairy Tail - Ending 19v2 [Lenny]" [1]=> string(33) "Fairy Tail - Ending 19v3 [Kagura]" [2]=> string(30) "Fairy Tail - Ending 19v4 [Mio]" } Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 8 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 Warning: Illegal string offset 'days' in /in/fRJg9 on line 10 array(4) { [0]=> string(31) "Fairy Tail - Ending 19v1 [Erza]" [1]=> string(30) "Fairy Tail - Ending 19v4 [Mio]" [2]=> string(33) "Fairy Tail - Ending 19v3 [Kagura]" [3]=> string(32) "Fairy Tail - Ending 19v2 [Lenny]" }
Output for 5.3.17 - 5.3.29
array(4) { [3]=> string(31) "Fairy Tail - Ending 19v1 [Erza]" [0]=> string(32) "Fairy Tail - Ending 19v2 [Lenny]" [1]=> string(33) "Fairy Tail - Ending 19v3 [Kagura]" [2]=> string(30) "Fairy Tail - Ending 19v4 [Mio]" } array(4) { [0]=> string(31) "Fairy Tail - Ending 19v1 [Erza]" [1]=> string(30) "Fairy Tail - Ending 19v4 [Mio]" [2]=> string(33) "Fairy Tail - Ending 19v3 [Kagura]" [3]=> string(32) "Fairy Tail - Ending 19v2 [Lenny]" }