1

I am returning an array of values using mysql_fetch_array.

In the while loop, i need to perform an if condition on the next element of the array.

E.g

if next($row) == 'test'
{
...
}

The thing is 'next($row)' is returning me the index of the next element in the array. I would like to test for the next $row("name").

if next($row("name")) == 'test'
    {
    ...
    } //this code is incorrect

Is there a way of doing this in php?

Thanks a lot for your help :)

1

2 Answers 2

2

if the "next($row)" gives you the index of the next cell in the array then just use it to perform the test. $arr[next($row)] = the next cell value/obj/whatever you have there

Sign up to request clarification or add additional context in comments.

Comments

1
foreach ($rows as $k => $row) {
    if (isset($rows[$k+1]) && $rows[$k+1] == 'test') //do something

    // Do normal stuff here
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.