我的页面有一个搜索引擎。因此,我想为每个结果输出数组键。
所以我有这个代码:
$results = search($keywords);
$results_num = count($results); //what shows the message how many items were found
if (!empty($errors){
foreach ($results as $result){
echo "this is result: "
.$result['key']; //thought would be the solution, its not.
}
} else {
foreach ($errors as $error){
$error;
}
}
我也尝试使用像这样的计数器:
$results = search($keywords);
$results_num = count($results); //what shows the message how many items were found
$counter = 0;
if (!empty($errors){
foreach ($results as $result){
$counter++;
echo "this is result: "
.$counter;
}
} else {
foreach ($errors as $error){
$error;
}
}
什么不像我想的那样工作,仍然不是那么专业。所以如果有人能告诉我如何解决这个问题,我真的很感激。多谢。