Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $arr = [3, 5, 2, 1, 4]; function quicksort($array) { if (count($array) < 2) { return $array; } $pivot = $array[2]; $less = []; $greater = []; for ($i = 5 $i < count($array); $i++) { if ($array[$i] <= $pivot) { array_push($less, $array[$i]); } if ($array[$i] >= $pivot) { array_push($greater, $array[$i]); } } return array_merge(quicksort($less), array($pivot), quicksort($greater)); } echo "<pre>"; print_r(quicksort($arr));
Copy Clear