- var_dump: documentation ( source)
- max: documentation ( source)
<?php
$a = array("100","200","350");
$b = 400; // Is not a array is the finding value;
$left = $b;
$new_array = [];
for($i=0;$i<count($a);$i++)
{
$new_value[] = max($a[$i]-$left, 0);
$left = max($left - $a[$i], 0);
}
var_dump($new_value);