Changeset 2694714
- Timestamp:
- 03/16/2022 09:47:20 AM (4 years ago)
- Location:
- what-if-bitcoin/trunk
- Files:
-
- 2 edited
-
functions/generate_form_result.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
what-if-bitcoin/trunk/functions/generate_form_result.php
r2641673 r2694714 14 14 add_action( 'wp_ajax_fetch_whatif_result', 'fetch_whatif_result_function' ); 15 15 add_action( 'wp_ajax_nopriv_fetch_whatif_result' ,'fetch_whatif_result_function' ); 16 17 function numberToCurrency($text,$number){ 18 $checkMinusVal = explode('-',$number)[0]; 19 $checkMinus = $final = ''; 20 $allStr = explode('.',$number); 21 if($checkMinusVal == ''){ 22 $checkMinus = '-'; 23 $allStr = explode('.',explode('-',$number)[1]); 24 } 25 $str = $allStr[0]; 26 $length = strlen($str); 27 $count = $first = 0; 28 for($i = $length; $i >= 0; $i--){ 29 if($count == 3 && $first == 0){ 30 $final .= $str[$i]; 31 if($str[$i + 1] != ''){ 32 $final .= ''; 33 } 34 $count = 0; 35 $first = 1; 36 } 37 elseif($count == 4 && $first == 1){ 38 if( ($i - 1) < 0){ 39 $final .= $str[$i]; 40 } 41 else{ 42 $final .= $str[$i].','; 43 } 44 $count = 0; 45 } 46 else{ 47 $final .= $str[$i]; 48 } 49 $count++; 50 } 51 $final = strrev($final); 52 if(array_key_exists("1",$allStr)){ 53 $decimalVal = $allStr[1][0]; 54 if(!empty($allStr[1][1])){ 55 $decimalVal .= $allStr[1][1]; 56 } 57 else{ 58 $decimalVal .= 0; 59 } 60 if($allStr[1][2] >= 5){ 61 $decimalVal++; 62 } 63 $final .= '.'.$decimalVal; 64 } 65 return $checkMinus.$text.$final; 66 } 16 67 17 68 function fetch_whatif_result_function() { … … 57 108 $select_data_result = $value; 58 109 } 59 60 $ profit = round($whatif_amount/$select_data_result*$current_price-$whatif_amount);61 $roi = round($profit/$whatif_amount*100);62 echo 'If you invested <b><span class="whatif_form_result_text">'.$text.$whatif_amount.'</span></b> in <i class="fa fa-btc"></i><b>BITCOIN</b> on <b><span class="whatif_form_result_text">'.$date.'</span></b> You would have made <b><span class="whatif_form_result_text">'.number_format( $roi).'%</span></b> ROI, that\'s <b><span class="whatif_form_result_text">'.$text.number_format($profit).'</span></b> in profit.';110 $profit = $whatif_amount/$select_data_result*$current_price-$whatif_amount; 111 $roi = $profit/$whatif_amount*100; 112 113 echo 'If you invested <b><span class="whatif_form_result_text">'.$text.$whatif_amount.'</span></b> in <i class="fa fa-btc"></i><b>BITCOIN</b> on <b><span class="whatif_form_result_text">'.$date.'</span></b> You would have made <b><span class="whatif_form_result_text">'.number_format(round($roi,1),2).'%</span></b> ROI, that\'s <b><span class="whatif_form_result_text">'.numberToCurrency($text,number_format(round($profit,1),2)).'</span></b> in profit.'; 63 114 } 64 115 ?> -
what-if-bitcoin/trunk/readme.txt
r2641684 r2694714 9 9 Donate link: https://techuptodate.com.au/what-if-bitcoin/ 10 10 Requires at least: 4.7 11 Tested up to: 5. 8.211 Tested up to: 5.9.1 12 12 Stable tag: 1.0.2 13 Version: 1.0. 313 Version: 1.0.4 14 14 License: GPLv2 or later 15 15 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.