Archimedees Posted October 18, 2007 Share Posted October 18, 2007 I need help with my script I have 3 arrays, $arStrings which contains a list of servers derived from two arrays $arServerPageLIst and $arServerPingList. $arServerPageList contains a list of servers derived from a file Page.conf. $arServerPingList contains a list of arrays from another file ping.conf. The servers are either set to active or inactive. Now, I want to walk though $arStrings with foreach $arStrings as $key => $value. If the server name is active, I have to look in $arServerPageList and $arServerPingList for this server and set active value to false. I intend to display $arString values in a table using a form and have a activate or deactivate link next to each server name. So when I click the activate/ deactivate link on the display, the respective active value in the array $arServerPageList or $arServerPingList should be set to true or false and finally the page or Ping files should be written anew to contain the changes. I need help to have this script reflect above logic. Thanks foreach ($arStrings as $key => $value) { if ($value["active"] == true) { $Needle = $value["name"]; array_search ($arServerPageList, $Needle) $i=0; $MaxPageServers = count($arServerPageList); for($i =0; $i<$MaxPageServers; $i++) { if($arServerPageList[$i]== $Needle) { $arCurrentPageServer = $arServerPageList[$i]; if ($arCurrentPageServer["active"]== true) { $arCurrentPageServer["active"]== false; } else { $arCurrentPageServer["active"]==true; } } //else do nothing } $Needle = $value["name"]; array_search ($arServerPingList, $Needle) $i=0; $MaxPingServers = count($arServerPingList); for($i =0; $i<$MaxPingServers; $i++) { if($arServerPingList[$i]== $Needle) { $arCurrentPingServer = $arServerPingList[$i]; if ($arCurrentPingeServer["active"]== true) { $arCurrentPingServer["active"]== false; } else { $arCurrentPingServer["active"]==true; } } //else do nothing } }//else do nothing Link to comment https://forums.phpfreaks.com/topic/73793-array-search-and-if-else-statements/ Share on other sites More sharing options...
Archimedees Posted October 18, 2007 Author Share Posted October 18, 2007 Please somebody? I have 3 arrays, $arStrings which contains a list of servers derived from two arrays $arServerPageLIst and $arServerPingList. $arServerPageList contains a list of servers derived from a file Page.conf. $arServerPingList contains a list of arrays from another file ping.conf. The servers are either set to active or inactive. Now, I want to walk though $arStrings with foreach $arStrings as $key => $value. If the server name is active, I have to look in $arServerPageList and $arServerPingList for this server and set active value to false. I intend to display $arString values in a table using a form and have a activate or deactivate link next to each server name. So when I click the activate/ deactivate link on the display, the respective active value in the array $arServerPageList or $arServerPingList should be set to true or false and finally the page or Ping files should be written anew to contain the changes. I need help finding logical inconsistencies in script below. Thanks foreach ($arStrings as $key => $value) { if ($value["active"] == true) { $Needle = $value["name"]; array_search ($arServerPageList, $Needle) $i=0; $MaxPageServers = count($arServerPageList); for($i =0; $i<$MaxPageServers; $i++) { if($arServerPageList[$i]== $Needle) { $arCurrentPageServer = $arServerPageList[$i]; if ($arCurrentPageServer["active"]== true) { $arCurrentPageServer["active"]== false; } else { $arCurrentPageServer["active"]==true; } } //else do nothing } $Needle = $value["name"]; array_search ($arServerPingList, $Needle) $i=0; $MaxPingServers = count($arServerPingList); for($i =0; $i<$MaxPingServers; $i++) { if($arServerPingList[$i]== $Needle) { $arCurrentPingServer = $arServerPingList[$i]; if ($arCurrentPingeServer["active"]== true) { $arCurrentPingServer["active"]== false; } else { $arCurrentPingServer["active"]==true; } } //else do nothing } }//else do nothing Link to comment https://forums.phpfreaks.com/topic/73793-array-search-and-if-else-statements/#findComment-372297 Share on other sites More sharing options...
MadTechie Posted October 18, 2007 Share Posted October 18, 2007 OKay it would help if we knew the array structure, also i am not sure what your asking.. instead of saying the logic you want.. can to tell us what you have and what you want at the end! Link to comment https://forums.phpfreaks.com/topic/73793-array-search-and-if-else-statements/#findComment-372304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.