我有一个包含查询搜索的所有结果的数组。
我的问题是我需要从这个数组中选择一行,然后才能选择下一行和上一行。
这是我的代码
function getUserProf(array $data, $faceid)
{
//make sure that all data is saved in an array
$userprof = array();
//makes the array with the info we need
foreach ($data as $val)
if ($val['faceid'] == $faceid){
$userprof = array ("id" => $val["id"], "total" => $val["total"], "faceid" => $val["faceid"], "lname" => $val["lname"], "fname" => $val["fname"], "hand" => $val["hand"], "shot1" => $val["shot1"], "shot1" => $val["shot1"], "shot2" => $val["shot2"], "shot3" => $val["shot3"], "shot4" => $val["shot4"], "shot5" => $val["shot5"]);
}
$next = next($data);//to get the next profile
$prev = prev($data);//to get the next profile
$userprofinfo = array('userprof' => $userprof, 'next' => $next);//make a array with the profile and the next prof and the prev prof
//we return an array with the info
return $userprofinfo;
}
这以某种方式起作用,但它没有给我正确的下一行和上一行?