我有这个伪代码,我一直在尝试为和创建正确的PHP语法 我绝对无处可去。我继续在函数group_job_items上得到一个Parse错误。
解析错误:语法错误,第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
}
}
}
答案 0 :(得分: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;
}
}
}
?>
答案 1 :(得分: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();
}
答案 2 :(得分:0)
提交的代码中存在一些语法错误。
此行末尾缺少右括号/括号:
if (!isset ($jobs_by_category[$name])
这一行末尾缺少一个分号:
$jobs_by_category[$name][] = $item
进行这些更正应解决PHP解析器错误。