If I have this data, how to get current & next array value based on specific key
$data = array(
array(
"name"=>"Joseph",
"location"=>"Wisconsin"
),
array(
"name"=>"Sally",
"location"=>"Toronto"
)
);
This is how I am doing it, but seems to not displaying what I expect it to be. Kindly assist.
foreach ($data as $val)
{
echo 'current:'.$val['name'].'<br/>';
$nextval = next($val);
echo 'next:'.$nextval['name'].'<br/>';
}
This is what is being printed out
current:Joseph
next:W
current:Sally
next:T
I expect it to be
current:Joseph
next:Sally
current:Sally
next:[..next value..]