Syntax Problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leathem
Forum Newbie
Posts: 9
Joined: Tue Sep 02, 2008 3:21 am

Syntax Problem.

Post by leathem »

Hello all,
i have a problem with a line of code, i have a multi dimensional array, i want to compare each value in each array to another and display a match. When the code is executed it compares all elements of all 3 arrays in the multidimensional array at once instead of goin through each array at a time, hope this is clear.
Heres The code

Code: Select all

unction summaryDisplay($dir_name, $filter, $rss)
{
  global $config;
  $groups = ($config["groups"]);
  $groupsArray = explode(' ', $groups);
  
 
 
  $projectsArrays = array();
  
  for($i = 0; $i < count($groupsArray); $i++)
  {
    $projectsArrays[$i] =  explode(' ', ($config[$groupsArray[$i].".projects"])); 
    echo "<test1>". $projectsArrays [$i][0]."</test1>";
  }
 
 
  for ($i = 0; $i < count($groupsArray); $i++){
        foreach ($projectsArrays as $tempZ) {  
 
        foreach ($tempZ as $tempA) {
        
          #displays the results  
          if ($tempA == $file_name) {  
            echo "<".$groupsArray[$i].">";
            echo "<project><name>".$file_name."</name><status>${status}</status>";
            echo "<latestresult>".$lastResult."</latestresult>";
            echo "<latestsuccess>".$lastSuccessfulBuild."</latestsuccess>";
            echo "<latestattempt>".($lastAttempt !== "" ? date($config["dateformat"], $lastAttempt) : "")."</latestattempt>";
            echo "<latestlabel>".$lastLabel."</latestlabel>";
            echo "<latestlog>".$lastLog."</latestlog>";
            echo "</project>";
            echo "</".$groupsArray[$i].">\n";
            
            
      if( $lastResult == "SUCCESS" )
        {
          $successCount++;
        }
      else if( $lastResult == "FAILURE" )
        {
          $failureCount++;
        }
            
          }//if
         }//foreach
      
      }//foreach
 
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Syntax Problem.

Post by califdon »

Check for "compare" in the descriptions of these array functions:
http://us2.php.net/array
Post Reply