Actually the code works already. Take a look at the following:
<?php
$string="#IB 0 2099 -226930.95
#IB 0 2510 -81219.00
#UB 0 2641 1114.28
#UB 0 2645 6978.00
#UB -1 2890 -43750.55
#RES 0 5800 46239.60
#RES -1 5900 574.92
#RES 0 5900 6402.63";
$arr = array_map(create_function('$a', 'return explode(\' \', $a);'), preg_split('/\n/', $string)); <---this line was made (99%
by Twey.
print_r($arr);
echo "<br><br>";
echo $arr[0][3]+$arr[2][3];
?>
The value is the answer from adding the two values mentioned above. I just think the code should be easier to use
. Gonna try and work on it some more, because this is kind of a cool script idea.
EDIT: I have the submit form created, so that all you have to do is type in the values 2099 and 2641 and it will add the two selected values from the two lines and come out with the answer of -225816.67. Just need to tie it into the above script.
EDIT: will the number that you want to add always be the 4th item on the row and/or the last item on the row and will the identifier always be in the 3rd column? Will the identifier always be unique? This script will assume that is the case. Either way I am almost done. Just give me 15min or so to work out the bugs.
EDIT: here is the code. I'll need to know a few more things about this data you are working with so as to avoid possible wrong answers. I am having a bit of fun with this code and will try to make it operate better. For now try this:
PHP Code:
<STYLE TYPE="TEXT/CSS">
textarea{background-color:#a9a9a9;color:black;}
body{
background-color:tan;
}
</style>
<?php
$data=@$_POST['data'];
$one=@$_POST['one'];$one=str_replace(" ","",$one);$onearr=explode(",",$one);
$url=@$_POST['url'];
if ($url != "")
{
$handle = file_get_contents("$url",NULL);
$data=htmlentities($handle);
}
$string="";
$arr=array_map(create_function('$a', 'return preg_split(\'[\s+]\', $a);'), preg_split('/\n/', $data));
$oops2=count($onearr);
$oops=count($arr);
$a=0;
while ($a<$oops)
{
$arr2 =$arr[$a][0];
$arr2 .=$arr[$a][1];
$arr2 .=$arr[$a][2];
array_unshift($arr[$a],$arr2);
array_unshift($arr[$a],"nerfed");
$a++;
}
?>
<form action=<?php echo $_SERVER['PHP_SELF']; ?> method="POST">
copy and place your data in here or enter the url where the data is stored<br>in the space provided at the end:<br>
<textarea name="data" cols=55 rows=25><?php echo "$data"; ?></textarea><br>
identifiers (remember to separate identifiers with commas): <br><textarea name= "one" cols=45 rows=3><?php echo "$one"; ?></textarea><br>
url of .txt document to scan (optional): <br><input type="text" name="url" size=75 value=<?php echo @$_POST['url']; ?> >
<br><br>
<input type='submit' name="queryButton" value="Submit and Add">
</form>
<?php
$a=0;$b=0;$c=0;$d=array(0);
while ($b<$oops2) {
while ($a<$oops) {
$ans=array_search($onearr[$b],$arr[$a]);
if ($ans==1) {$c++;echo "Result $c is located at array[$a][$ans].";array_push($d,$arr[$a][5]); echo $arr[$a][5];echo "<br>";}
$a++;
}$b++;$a=0;
}
$ans1=array_sum($d);
echo ".<br><br>If you add the values of these identifiers together you will get $ans1";
?>
EDIT: updated the code to make it easier to use. The above code makes certain assumptions as stated in the second edit listed above. If you need the code modified or to behave differently let me know and I'll see what I can do. 
EDIT: Fixed a tiny bug. The script will now only return a result if the identifier selected is found in the third column as opposed to anywhere in the data.
EDIT: I noticed that the column you listed as your identifier has two numbers that are the same. How would you like the program to handle that? Add both numbers for a total of three values when there is more than one identifier with the same value? Also updated the script to handle multiple spaces.
EDIT: Fixed a minor bug. Added the ability to list the url of the text document to search (with thanks to thetestingsite and this thread). Added some style to make it easier on the eyes. Made it cross browser compatible.
P.S. I strongly encourage you to get acquainted with MySQL. I have found it to be much simpler than PHP. MySQL is nothing more than a glorified spreadsheet. Working around MySQL will make coding much more difficult. For example I can have 50 pages that are very similar. In 15 seconds or much less I can update all 50 pages. It's a lifesaver really.
Bookmarks