hchsk Posted May 11, 2009 Share Posted May 11, 2009 hi, i can't seem to find the problem in this foreach loop. if anyone could help or give a suggestion, i'd really appreciate it, it's been endless trouble. as far as i can tell, the foreach loop isnt executing at all, even though its been given a valid array and format. the purpose of the code is to check if the time given by the function inactive() is in a certain range, if so, add an item to the rss page this code is within. but to also check it doesnt issue the same warning twice, and also to do this for multiple inactive($vars). $nodoubleiw == 000000000000 at the start, and should be updated every time something changes. (each digit represents a team, and their inactivity status, 1-3) //INCLUDE INACTIVITY.PHP include("scripts/inactivity.php"); //OPEN NODOUBLEIW.TXT $myFile = "../nodoubleiw.txt"; $nodoubleiw = file($myFile); ////CHECK FOR INACTIVITY ///killinactivedoubles.txt == 000000000000 ///0 == none issued ///1 == 6hr issued ///2 == 1hr issued ///3 == inactivity issued ///change value of teams slot when issued (+=1) ///if not inactive reset value of teams slot $nodoubleiw = preg_split('//', $nodoubleiw[0], -1,PREG_SPLIT_NO_EMPTY); //this is not functioning -> troubleshoot foreach ($nodoubleiw as $key => $value) { $search = 'team' . ($key+1); $inactive = inactive($search); if ((intval($value) == 3) && (stristr($inactive, 'inactive') == false)) {$value = 0;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 6)) {$warning = $team . 'is in danger of inactivity! Less than 6 hours left!'; $value += 1;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 1)) {$warning = $team . 'is in danger of inactivity! Less than 1 hour left!'; $value += 1;} if (intval($inactive[seconds]) <= 0) {$warning = $team . 'has been declared inactive. If you are the Captain of ' . $team . ', please contact a judge for information concerning your shootout.'; $value += 1;} $newnodoubleiw = $value; } //UPDATE NODOUBLEIW.TXT $myFile = "../nodoubleiw.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, $newnodoubleiw); Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/ Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 typo in my copy & paste, but not in the real thing. $newnodoubleiw = $value; should be $newnodoubleiw .= $value; also, note, replacing the foreach loop with foreach ($nodoubleiw as $key => $value) { $newnodoubleiw = 'whyy'; } also returns a blank $newnodoubleiw. why could this be? Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831308 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Before the foreach, slap this line: var_dump($nodoubleiw); Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831326 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 first thing i did, but couldnt glean anything from it array(12) { [0]=> string(1) "0" [1]=> string(1) "0" [2]=> string(1) "0" [3]=> string(1) "0" [4]=> string(1) "0" [5]=> string(1) "0" [6]=> string(1) "0" [7]=> string(1) "0" [8]=> string(1) "0" [9]=> string(1) "0" [10]=> string(1) "0" [11]=> string(1) "0" } Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831329 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Ohk.. that's just weird. $value is the value. Changing it doesn't update the array. If you want to update something, do $nodoubleiw[$key] = $somevalue. Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831331 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 i tried this, still to a blank value of $newnodoubleiw foreach ($nodoubleiw as $key => $value) { $search = 'team' . ($key+1); $inactive = inactive($search); if ((intval($value) == 3) && (stristr($inactive, 'inactive') == false)) {$nodoubleiw[$key] = 0;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 6)) {$warning = $team . 'is in danger of inactivity! Less than 6 hours left!'; $nodoubleiw[$key] += 1;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 1)) {$warning = $team . 'is in danger of inactivity! Less than 1 hour left!'; $nodoubleiw[$key] += 1;} if (intval($inactive[seconds]) <= 0) {$warning = $team . 'has been declared inactive. If you are the Captain of ' . $team . ', please contact a judge for information concerning your shootout.'; $nodoubleiw[$key] += 1;} $newnodoubleiw .= $nodoubleiw[$key]; } thanks for the help Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831334 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 In the foreach, after $inactive = inactive($search), put: var_dump($inactive); Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831340 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(15) ["display"]=> string(6) "2:18:8" } array(6) { ["years"]=> int(0) ["days"]=> float(2) ["hours"]=> float(18) ["minutes"]=> float( ["seconds"]=> float(14) ["display"]=> string(6) "2:18:8" } Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831342 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 None of those IF statements are true from what I see. Perhaps that's why. Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831343 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 right, so it should be the original value from //OPEN NODOUBLEIW.TXT $myFile = "../nodoubleiw.txt"; $nodoubleiw = file($myFile); which would be "0" and $newnodoubleiw should == 000000000000 Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831344 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Well no, you overwrote it here: $nodoubleiw = preg_split('//', $nodoubleiw[0], -1,PREG_SPLIT_NO_EMPTY); Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831346 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 that just broke it down into an array by character to allow the foreach to loop through it each time the loop hits $newnodoubleiw .= $value; it should be appending the $value from the foreach loop (possibly +=1 if a statement was true) Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831347 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Try - $newnodoubleiw = ''; foreach ($nodoubleiw as $key => $value) { $search = 'team' . ($key+1); $inactive = inactive($search); $newval = intval($value); if ((intval($value) == 3) && (stristr($inactive, 'inactive') == false)) {$newval = 0;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 6)) {$warning = $team . 'is in danger of inactivity! Less than 6 hours left!'; $newval += 1;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 1)) {$warning = $team . 'is in danger of inactivity! Less than 1 hour left!'; $newval += 1;} if (intval($inactive[seconds]) <= 0) {$warning = $team . 'has been declared inactive. If you are the Captain of ' . $team . ', please contact a judge for information concerning your shootout.'; $newval += 1;} $newnodoubleiw .= $newval; } Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831349 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 haha, your script has a mistake in concatenating $value instead of $nodoubleiw[$key], but otherwise, works perfectly! thanks so much! lol, we were typing at the same time. i solved it slightly differently too. interesting. thanks again. Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831351 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 ahh, while that worked in a test.php i was using, it still breaks in the real page im using it in, that constructs an rss. maybe you could help find the error here as well? im going to post the full script, but it is clearly labeled, and the vast majority of it you can ignore. <?php //CHECK WHEN LAST MODIFIED AND ASSIGN TO VAR $lastmod = date("D, j M Y H:i:s", (filemtime("report.txt"))); $lastmod += 10000; //GET CURRENT DATE/TIME $now = date("D, j M Y H:i:s"); $ltime = time() + 3*60*60 ; $nowpub = date('D, j M Y H:i:s',$ltime); //GET LAST UPDATE $lastupdate = date("D, j M Y H:i:s", (filemtime("modifycheck.txt"))); //GET DIFFERENCE $lastissue = strtotime($now) - strtotime($lastupdate); //GET SCORES $filename = "scorestore.txt"; $score = file($filename); //GET COMMENT $filename = "comments.txt"; $comment = file($filename); //GET REPORT $filename = "report.txt"; $report = file($filename); echo <<<END <rss version="2.0"> <channel> <title>HCHSLive Network Feed</title> <link>http://www.lowersouthlounge.com</link> <pubDate>Wed, 29 Apr 2009 08:10:00 EST</pubDate> <description>HCHS Live Network</description> <language>en-us</language> <lastBuildDate>Wed, 29 Apr 2009 08:10:00 EST</lastBuildDate> <managingEditor>[email protected]</managingEditor> <webMaster>[email protected]</webMaster> <image> <title>HCHSLive Network Feed</title> <url>http://www.lowersouthlounge.com/favicon.ico</url> <link>http://lowersouthlounge.com</link> <width>16</width> <height>16</height> </image> END; ///////////////////////// ///////////////////////////////////////////////////////////////// FINISH ME! /////////////////////////////////// //INCLUDE INACTIVITY.PHP include("scripts/inactivity.php"); //OPEN NODOUBLEIW.TXT $myFile = "../nodoubleiw.txt"; $nodoubleiw = file($myFile); ////CHECK FOR INACTIVITY ///killinactivedoubles.txt == 000000000000 ///0 == none issued ///1 == 6hr issued ///2 == 1hr issued ///3 == inactivity issued ///change value of teams slot when issued (+=1) ///if not inactive reset value of teams slot $nodoubleiw = preg_split('//', $nodoubleiw[0], -1,PREG_SPLIT_NO_EMPTY); //this is not functioning -> troubleshoot $newnodoubleiw = ''; foreach ($nodoubleiw as $key => $value) { $search = 'team' . ($key+1); $inactive = inactive($search); if ((intval($value) == 3) && (stristr($inactive, 'inactive') == false)) {$nodoubleiw[$key] = 0;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 6)) {$warning = $team . 'is in danger of inactivity! Less than 6 hours left!'; $nodoubleiw[$key] += 1;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 1)) {$warning = $team . 'is in danger of inactivity! Less than 1 hour left!'; $nodoubleiw[$key] += 1;} if (intval($inactive[seconds]) <= 0) {$warning = $team . 'has been declared inactive. If you are the Captain of ' . $team . ', please contact a judge for information concerning your shootout.'; $value += 1;} $newnodoubleiw .= $nodoubleiw[$key]; } ////UPDATE NODOUBLEIW.TXT //$myFile = "../nodoubleiw.txt"; //$fh = fopen($myFile, 'w'); //fwrite($fh, $newnodoubleiw); ////CREATE WARNING TO BE APPENDED TO ADDFEED.TXT //$warning .= ' //<item> // <title>HCHSLive Network Update</title> // <category>inactivity</category> // <link>http://lowersouthlounge.com/circle.php</link> // <description>$warning</description> // <pubDate>$LASTEVENTTIME</pubDate> //</item>'; ////TWEET! //include("tweet.php"); //postToTwitter("HCHSLiveNetwork", "password", $newreport); ///////////////////////// ///////////////////////////////////////////////////////////////// FINISH ME! /////////////////////////////////// //SAVE OLDFEED AS $originalfeed $myFile = "addfeed.txt"; $fh = fopen($myFile, 'r'); $originalfeed = fread($fh, filesize($myFile)); fclose($fh); //CHECK IF NEW INFO if ($lastissue > 0){ //CREATE NEW ITEM for ( $counter = 0; $counter < count($report); $counter += 1 ) { //MAKE CATEGORY for ( $counter2 = 1; $counter2 <= 12; $counter2 += 1 ) { //////////////////////////////////////////////////////////////////CHANGE FUNCTION TO CHECK FOR TEAM NAMES $hold = 'team' . $counter2 . ' '; //SPACE CHECKS FOR ERRORS DUE TO DIGIT REPEAT AT 10+ if (stristr($report[$counter], $hold) != false) {$category = $category . trim($hold) . '/';} } $luck = rand(0, 34); if (trim($report[$counter]) !== '') { $newfeed = $newfeed . " <item> <title>HCHSLive Network Update</title> <category>$category</category> <link>http://lowersouthlounge.com/circle.php</link> <description>$report[$counter] $comment[$luck]</description> <pubDate>$nowpub</pubDate> </item>"; } } //OVERWRITE FILE, FIRST NEW ITEM THEN $originalfeed $myFile = "addfeed.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, " $warning $newfeed $originalfeed"); fclose($fh); //EMPTY REPORT.TXT $myFile = "report.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, ""); fclose($fh); //CHANGE modifycheck.txt $myFile = "modifycheck.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, "$now"); fclose($fh); } echo <<<END $newfeed $originalfeed <item> <title>RSS Feed Live!</title> <category>post</category> <link>http://lowersouthlounge.com</link> <description> HCHS Live Network RSS feed running! TIME STAMP: $lastmod $lastupdate $now || $newnodoubleiw </description> <pubDate>Mon, 27 Apr 2009 08:10:00 EDT</pubDate> </item> </channel> </rss> END; ?> Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831352 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Can you put my edited code in replacement of yours? Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831355 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 same result. both versions work in a normal html document with an inline php include and print $newnodoubleiw appended Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831356 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Okay post the updated code and tell me what's NOT working. Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831357 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 <?php //CHECK WHEN LAST MODIFIED AND ASSIGN TO VAR $lastmod = date("D, j M Y H:i:s", (filemtime("report.txt"))); $lastmod += 10000; //GET CURRENT DATE/TIME $now = date("D, j M Y H:i:s"); $ltime = time() + 3*60*60 ; $nowpub = date('D, j M Y H:i:s',$ltime); //GET LAST UPDATE $lastupdate = date("D, j M Y H:i:s", (filemtime("modifycheck.txt"))); //GET DIFFERENCE $lastissue = strtotime($now) - strtotime($lastupdate); //GET SCORES $filename = "scorestore.txt"; $score = file($filename); //GET COMMENT $filename = "comments.txt"; $comment = file($filename); //GET REPORT $filename = "report.txt"; $report = file($filename); echo <<<END <rss version="2.0"> <channel> <title>HCHSLive Network Feed</title> <link>http://www.lowersouthlounge.com</link> <pubDate>Wed, 29 Apr 2009 08:10:00 EST</pubDate> <description>HCHS Live Network</description> <language>en-us</language> <lastBuildDate>Wed, 29 Apr 2009 08:10:00 EST</lastBuildDate> <managingEditor>[email protected]</managingEditor> <webMaster>[email protected]</webMaster> <image> <title>HCHSLive Network Feed</title> <url>http://www.lowersouthlounge.com/favicon.ico</url> <link>http://lowersouthlounge.com</link> <width>16</width> <height>16</height> </image> END; ///////////////////////// ///////////////////////////////////////////////////////////////// FINISH ME! /////////////////////////////////// //INCLUDE INACTIVITY.PHP include("scripts/inactivity.php"); //OPEN NODOUBLEIW.TXT $myFile = "../nodoubleiw.txt"; $nodoubleiw = file($myFile); ////CHECK FOR INACTIVITY ///killinactivedoubles.txt == 000000000000 ///0 == none issued ///1 == 6hr issued ///2 == 1hr issued ///3 == inactivity issued ///change value of teams slot when issued (+=1) ///if not inactive reset value of teams slot $nodoubleiw = preg_split('//', $nodoubleiw[0], -1,PREG_SPLIT_NO_EMPTY); //this is not functioning -> troubleshoot $newnodoubleiw = ''; foreach ($nodoubleiw as $key => $value) { $search = 'team' . ($key+1); $inactive = inactive($search); $newval = intval($value); if ((intval($value) == 3) && (stristr($inactive, 'inactive') == false)) {$newval = 0;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 6)) {$warning = $team . 'is in danger of inactivity! Less than 6 hours left!'; $newval += 1;} if ((intval($inactive[days]) == 0) && (intval($inactive[hours]) <= 1)) {$warning = $team . 'is in danger of inactivity! Less than 1 hour left!'; $newval += 1;} if (intval($inactive[seconds]) <= 0) {$warning = $team . 'has been declared inactive. If you are the Captain of ' . $team . ', please contact a judge for information concerning your shootout.'; $newval += 1;} $newnodoubleiw .= $newval; } ////UPDATE NODOUBLEIW.TXT //$myFile = "../nodoubleiw.txt"; //$fh = fopen($myFile, 'w'); //fwrite($fh, $newnodoubleiw); ////CREATE WARNING TO BE APPENDED TO ADDFEED.TXT //$warning .= ' //<item> // <title>HCHSLive Network Update</title> // <category>inactivity</category> // <link>http://lowersouthlounge.com/circle.php</link> // <description>$warning</description> // <pubDate>$LASTEVENTTIME</pubDate> //</item>'; ////TWEET! //include("tweet.php"); //postToTwitter("HCHSLiveNetwork", "password", $newreport); ///////////////////////// ///////////////////////////////////////////////////////////////// FINISH ME! /////////////////////////////////// //SAVE OLDFEED AS $originalfeed $myFile = "addfeed.txt"; $fh = fopen($myFile, 'r'); $originalfeed = fread($fh, filesize($myFile)); fclose($fh); //CHECK IF NEW INFO if ($lastissue > 0){ //CREATE NEW ITEM for ( $counter = 0; $counter < count($report); $counter += 1 ) { //MAKE CATEGORY for ( $counter2 = 1; $counter2 <= 12; $counter2 += 1 ) { //////////////////////////////////////////////////////////////////CHANGE FUNCTION TO CHECK FOR TEAM NAMES $hold = 'team' . $counter2 . ' '; //SPACE CHECKS FOR ERRORS DUE TO DIGIT REPEAT AT 10+ if (stristr($report[$counter], $hold) != false) {$category = $category . trim($hold) . '/';} } $luck = rand(0, 34); if (trim($report[$counter]) !== '') { $newfeed = $newfeed . " <item> <title>HCHSLive Network Update</title> <category>$category</category> <link>http://lowersouthlounge.com/circle.php</link> <description>$report[$counter] $comment[$luck]</description> <pubDate>$nowpub</pubDate> </item>"; } } //OVERWRITE FILE, FIRST NEW ITEM THEN $originalfeed $myFile = "addfeed.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, " $warning $newfeed $originalfeed"); fclose($fh); //EMPTY REPORT.TXT $myFile = "report.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, ""); fclose($fh); //CHANGE modifycheck.txt $myFile = "modifycheck.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, "$now"); fclose($fh); } echo <<<END $newfeed $originalfeed <item> <title>RSS Feed Live!</title> <category>post</category> <link>http://lowersouthlounge.com</link> <description> HCHS Live Network RSS feed running! TIME STAMP: $lastmod $lastupdate $now || $newnodoubleiw </description> <pubDate>Mon, 27 Apr 2009 08:10:00 EDT</pubDate> </item> </channel> </rss> END; ?> is not printing $newnodoubleiw in the final item. eventually, instead of doing this, it will update the nodoubleiw.txt file instead of printing, but this is to make testing the code easier until it works ////UPDATE NODOUBLEIW.TXT //$myFile = "../nodoubleiw.txt"; //$fh = fopen($myFile, 'w'); //fwrite($fh, $newnodoubleiw); Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831358 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 ??? So what are you trying to do with nodoubleiw.txt? I don't quite understand. Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831363 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 i dont think you need to worry about that right now, right now i just need the loop to work, and to be able to print $newnodoubleiw which should == 000000000000, and DOES when this is checked separately. what i will do once that works, is to delete the print command, and instead ////UPDATE NODOUBLEIW.TXT $myFile = "../nodoubleiw.txt"; $fh = fopen($myFile, 'w'); fwrite($fh, $newnodoubleiw); which will overwrite nodoubleiw.txt with the new $newnodoubleiw nodoubleiw.txt is a flat file database that keeps track of inactivity statuses Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831367 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Can you put these at the end of the foreach? var_dump($inactive); var_dump($newval); var_dump($newnodoubleiw); Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831371 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 i can by testing it outside of the rss with test.php and inline code (but there it works anyway). but i cant in the rss, because the rss will not display if the php prints improper format. but i can achieve what youre asking by assigning those dumps to vars and printing it within an item. the result of that is. . . nothing. it seems like the loop just isnt executing at all. i don't understand it. Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831375 Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Is your file path correct? I see all the other txt files in the . directory, but nodoubleiw.txt at the parent or .. directory. Is that right? Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831383 Share on other sites More sharing options...
hchsk Posted May 11, 2009 Author Share Posted May 11, 2009 i dont understand. my filepaths where? its already been demonstrated that all of the arrays are correctly filled, and i'm not overwriting the file yet, i'm just printing a variable! forget about all this code, even this does not work!! : foreach ($nodoubleiw as $key => $value) { $newnodoubleiw = 'whynot?'; } funny thing is that is does in the inline, test.php, but it fails in the rss.php but if i place $newnodoubleiw = 'aha'; right outside of the foeach loop, it works! Link to comment https://forums.phpfreaks.com/topic/157648-loop-problem/#findComment-831387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.