Cabal Posted August 13, 2007 Share Posted August 13, 2007 Any idea whats going on here? I have a function which outputs an image to a filename which is specified by a combination of a variable inputted into the function, and a hard-coded location. The variable is being inputted to the function correctly - i placed an echo command the line before the function is called and that value is correct..... however an echo command within the function seems to show a different value. It is this changed value which is being used as the location, not the correct one which is being sent to the function 8081_B12345_53444900_10 becomes 8081_B12345_53444900_14 8081_B12345_53444900_U99 becomes 8081_B12345_53444900_V03 8081_B12345_53444900_aa becomes 8081_B12345_53444900_ae Any idea what is causing this? It shouldn't be my coding as between the two echo commands all that happens is the value is passed to the function. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted August 13, 2007 Share Posted August 13, 2007 in the funciton, the value is reinterpreted, transfered. think about it: $d = 1; function der($e); { } der($d); it transfers the data, and can easily change. and if you use DATE in that function anywhere to predict it... it will get the date AGAIN at the function start. the important question is... what do you ahve to choose your last value? ??_??_??_xx what do you ahve determining that last section after the underscore? Quote Link to comment Share on other sites More sharing options...
PhaZZed Posted August 13, 2007 Share Posted August 13, 2007 Grab a pastebin, and let's take a look at the code.. Quote Link to comment Share on other sites More sharing options...
Cabal Posted August 13, 2007 Author Share Posted August 13, 2007 The value passed to the function is taken from an array value. The last bit of the file name corresponds to the file name without extension of a text file that was uploaded... this function translates the data within that file into an image. The whole of that value (the other bits... plus the file name without extension) are all put into an array. This is then looped and passed to the function. The values have different names and dont reference each other except being passed into a function. The start of the function is as follows function biodraw($values, $maxx, $maxy, $points, $bimt) { //this echo doesn't show the correct value - shows the incorrect value echo "$bimt<br>"; <SNIPPED.... AS IRRELEVANT UNDER HERE> The section of code that passes the value to the function is as follows //get the original file name from the array of file name $thisfilename = substr(strrchr($okfilearray[$oki], '/'), 1); $thisfilename = substr($thisfilename, 0, strrpos($thisfilename, 46)); //take the values from the output of a function (this part doesnt reference the file name at all) //this is simply the output from the function which reads the relevant data from the file $valdrawarray = $thisresult[4]; //declare variables $maxx = "1"; $maxy = "1"; $points = "0"; $imt = $thisfilename; //this bit shows the correct value echo "$imt<br>"; if(is_array($valdrawarray)) { foreach($valdrawarray as $thisvaldraw) { if($thisvaldraw[0] > $maxx) { $maxx = $thisvaldraw[0]; } if($thisvaldraw[1] > $maxy) { $maxy = $thisvaldraw[1]; } $points++; $imt++; } biodraw($valdrawarray, $maxx, $maxy, $points, $imt); } Quote Link to comment Share on other sites More sharing options...
sasa Posted August 13, 2007 Share Posted August 13, 2007 in line $imt++; the value is chenged try to insert line echo 'biodraw(',"$valdrawarray, $maxx, $maxy, $points, $imt",')'; and see Quote Link to comment Share on other sites More sharing options...
Cabal Posted August 13, 2007 Author Share Posted August 13, 2007 Ah.... that should be $imtcount++.... which is why I didn't check that line. Thanks for that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.