val [ ] is for storing maximum profit for each weight wt [ ] is for storing weights n number of item W maximum capacity of bag mat [ 2 ] [ W + 1 ] to store final result
< ? php function KnapSack ( & $ val , & $ wt , $ n , $ W ) {