Jump to content

Array search and if else statements


Archimedees

Recommended Posts

 

 

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.