mherr170 Posted February 24, 2008 Share Posted February 24, 2008 Hello Everyone, THanks to all who helped contribute to my last post! I have returned for another question, this time regarding variables not seemingly holding the correct info. A little background: I have a text file with the rise and set times for the sun for everyday in the year 08. I am reading it in, and setting the rise and set times for a Day object, which is contained in array in a Month object. WHen reading in the information, i perform set methods to enter the data, and then I immediately use the get methods to print out the values I just set. While reading in, they are the same. Even the variable that is getting the information is printing out with the correct value. For Example.. $first = strtok($t," "); for($i = 0; $i < strlen($t); $i++) { $second = strtok(" "); // echo "s= "; // echo $second; <-- HOLDS CORRECT DATA HERE // echo " "; //If second is null, it is the end of the line and break. if($second == false) { break; } //Sets the sunrise time $monthVect[$month]->dayVect[$day]->setRise($second); //echo "getRise= "; //echo $monthVect[$month]->dayVect[$day]->getRise(); <-- RETURNS CORRECT DATA //Move onto the next token // $second = strtok(" "); $third = strtok(" "); //echo "third equals "; //echo $third; <-- AGAIN holds correct data //echo " "; //Again, if null, end of line and break. //if($second == false) if($third == false) { break; } //Sets the sunset time. $monthVect[$month]->dayVect[$day]->setSet($third); //echo "getSet= "; //echo $monthVect[$month]->dayVect[$day]->getSet(); <-- and returns correct data $month++; }//end of for loop $day++; }// end of <= 38 IF However, further down my file when I am trying to out put the information based on any given day a user picks, no matter what I try to do, the getRise and getSet functions seem to be returning the same value! $conVert = $monthVect[$monthIndex]->dayVect[$dayIndex-2]->getRise(); $conVert2 = $monthVect[$monthIndex]->dayVect[$dayIndex-2]->getSet(); //echo "conVert="; //echo $conVert; <-- ALREADY HOLDS WRONG DATA! // <-- Even though this variable is returning from the getRise function, it already holds the value of the getSet function. //echo $monthVect[$monthIndex]->dayVect[$dayIndex-2]->getRise(); //echo $monthVect[$monthIndex]->dayVect[$dayIndex-2]->getSet(); //And here, the above will print the same number twice, the set time. Can anyone possibly understand why this is? I have been looking over this for days and, to me, the code just isn't making sense. However I'm sure there is something small I've missed. Can anyone see anything I could be doing wrong? THanks! -Mike Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 24, 2008 Share Posted February 24, 2008 you're using functions that aren't posted. can you post the object and it's functions? Quote Link to comment Share on other sites More sharing options...
mherr170 Posted February 24, 2008 Author Share Posted February 24, 2008 My Mistake, I've fixed the problem however! No more need for this post. Thanks Blue for posting! 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.