H there - firs time posting here - I will spare letting you know that I'm "new to PHP and Perl", as that will become painfully obvious below.
Below is a script I wrote to scrape a bank's asset amount, multiply it by 3% and display the results. I explain my flow idea below, and show the result I am getting compared to what I should be getting. My guess is that I can't do math with a value that is still inside an array. Is there an implode process I'm missing before I can start doing some math.
The URL I'm scraping is on my server so run at will.
<?php
// scrape page content of credit union
$dataassets = file_get_contents('http://ablistings.com/boise-project.htm');
// define regular expression to grab credit union's assets amount
$regexassets = '/members,\s(.+?)\smillion/';
// run the preg_match
preg_match($regexassets,$dataassets,$matchassets);
// print the second key of the array [1] which is just the numerical value (in this case $214.4)
$assetsamount = print_r($matchassets[1]);
// add 3% to the value of $214.4, so first we multiple .03 by value
$three_percent_increase = ($assetsamount * .03); // should egual 6.432
// now add the percentage to the orginal asset amount - in this case 6.432 + 214.4 which = 220.832
$final_sum = ($three_percent_increase + $assetsamount);
echo $final_sum;
// sum should be $220.832 but the sum this script produces is $214.41.03
?>