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 $amount = 27; $wareh = 4 $wareh_id = [ /*'3' => 3, '2' => 2, '1' => 1, '0' => 0*/ ]; arsort($wareh_id); $i= 0; $arr=[]; foreach($wareh_id as $key=>$value){ $arr[$key] = floor($amount / ($wareh - $i)); $i++; } $arr[$key] += $num - array_sum($arr);
Copy Clear