Array and foreach lopp with decimals. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Array and foreach lopp with decimals. (/showthread.php?tid=66985) |
Array and foreach lopp with decimals. - fedde - 12-28-2016 Been twisting my head on a foreach loop that decreses tokens. Attaching code that runs. What i try is to run trough the orders with same price (4 in total here, but after 3 are processed, i can not make it break. Also total tokens/coins add up to 4000 and should go up to 5000 leaving last order with xxxx coins left. Also the < > in the if statements are acting funny, probarly due it's a 8 digit decimal to play with. The break should be the $user_amout initially and update the last order with remaining tokens to database. PHP Code: $user_price = '0.00002450'; the result i get when running it with the var dump included. Code: We found Price a match Thanks for any help! RE: Array and foreach lopp with decimals. - InsiteFX - 12-28-2016 When is a decimal number a string? RE: Array and foreach lopp with decimals. - fedde - 12-28-2016 Should they be processed the floatval($value) on each of the decimal numbers ? If this is the case, things looks abit more easy to make work. |