2014-01-09 4 views
-1

정확한 PHP 구문을 작성하려고 시도한 적이있는 의사 코드가 있습니다. 나는 절대적으로 아무 곳에도 나타나지 않습니다. 나는 group_job_items 함수에서 Parse 에러를 계속 얻는다.if 문에서 PHP 구문 구문 오류가 발생했습니다.

Parse error: syntax error, unexpected '{' on line 17

여기에 무슨 문제가 있습니까? 어떤 도움이라도 대단히 감사하겠습니다. 제출 된 코드에서

function group_job_items() 
{ 
    $jobs_by_category = array(); 
    foreach ($category_name as $category_id => $name) 
    { 
     foreach ($job_item as $item) 
     { 
      // skip job items that do not match the current category 
      if ($item["category_id"] != $category_id) continue; 

      if (!isset ($jobs_by_category[$name]) 
      { 
       // create a list of jobs for the current category 
       $jobs_by_category[$name] = array(); 
      } 

      // add the current job item to the current category 
      $jobs_by_category[$name][] = $item 
     } 
    } 
} 
+1

여는 괄호와 닫는 괄호를 계산하십시오. 너는 닫는 것을 놓치고있다. – Gumbo

답변

1
<?php 

function group_job_items() 
{ 
    $jobs_by_category = array(); 
    foreach ($category_name as $category_id => $name) 
    { 
     foreach ($job_item as $item) 
     { 
      // skip job items that do not match the current category 
      if ($item["category_id"] != $category_id) continue; 

      if (!isset ($jobs_by_category[$name])) 
      { 
       // create a list of jobs for the current category 
       $jobs_by_category[$name] = array(); 
      } 

      // add the current job item to the current category 
      $jobs_by_category[$name][] = $item; 
     } 
    } 
} 
?> 
0

변경 ...

if (!isset ($jobs_by_category[$name]) 
      { 
       // create a list of jobs for the current category 
       $jobs_by_category[$name] = array(); 
      } 

if (!isset ($jobs_by_category[$name])) 
      { 
       // create a list of jobs for the current category 
       $jobs_by_category[$name] = array(); 
      } 
0

이 몇 가지 구문 오류. 이러한 수정을 만드는 것은 해결해야

$jobs_by_category[$name][] = $item 

:

if (!isset ($jobs_by_category[$name]) 

세미콜론이 줄의 끝에서 누락되었습니다

닫는 괄호/브라켓이 줄 끝에 없습니다 PHP 파서 오류.

관련 문제