<?php $stock = array("7", "5", "3"); $request = array("3", "6", "3"); var_dump(validate_order($stock, $request)); // false $stock = array("7", "5", "3"); $request = array("3", "4", "3"); var_dump(validate_order($stock, $request)); // true function validate_order($stock, $request) { foreach ($stock as $key=>$value) // Fixed length, loop through if ($value < $request[$key]) return false; // Return false only if the stock is less than the request return true; // If all indexes are higher in stock than request, return true }
You have javascript disabled. You will not be able to edit any code.