3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { function __construct() { $this->arr = array(1,34,3,98,9,76,45,4); } function joinNumbers($a, $b) { $t=10; while($b>=$t) $t*=10; return $a*$t+$b; } function arrangeNumbers() { $size=count($this->arr)/count($this->arr[0]); for($i=0;$i<$size-1;$i++) { for($j=$i+1;$j<$size;$j++) { if($this->joinNumbers($this->arr[$i],$this->arr[$j])<$this->joinNumbers($this->arr[$j],$this->arr[$i])) { $temp = $this->arr[$i]; $this->arr[$i] = $this->arr[$j]; $this->arr[$j] = $this->arr[$i]; } } } printf("Number is : "); for($i=0;$i<$size;$i++) { printf("%d",$this->arr[$i]); } printf("\n\n"); } } $test = new A; $test->arrangeNumbers();
based on BI4vt
Output for 7.2.0
Warning: count(): Parameter must be an array or an object that implements Countable in /in/lQ3Xl on line 17 Number is : 9999976454
Output for 5.3.21 - 7.1.10
Number is : 9999976454