Welcome Guest, Not a member yet? Register   Sign In
finding value of next element in an array
#1

[eluser]vtatds[/eluser]
In my view, I'm doing a foreach loop:
foreach($results as $result){
if ($result == 'noresults'){echo 'There are no results';}
else{echo $result->activity_name;}

in the else, i want to check if the next element in the array has the same value as the current. I need to write a div prior to it if it has the same value (to hide it for an accordian), and not write a div if it does not have the same value.

i feel like i'm missing something simple here. I thought next() would do it but i get a php error if i do next($result->activity_name) stating that php is expecting a string.

any thoughts? need more explanation to make it clearer?


Messages In This Thread
finding value of next element in an array - by El Forum - 09-08-2010, 08:59 PM
finding value of next element in an array - by El Forum - 09-09-2010, 01:02 AM
finding value of next element in an array - by El Forum - 09-09-2010, 01:08 AM
finding value of next element in an array - by El Forum - 09-09-2010, 09:09 AM
finding value of next element in an array - by El Forum - 09-09-2010, 09:42 AM
finding value of next element in an array - by El Forum - 09-09-2010, 11:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB