Re: Finding next recored in a array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 4:14 PM -0400 9/19/07, brian wrote:
tedd wrote:
At 11:52 AM -0400 9/17/07, brian wrote:

tedd wrote:

Richard Kurth wrote:

$Campaign_array| = array('0','1','3','5','8','15','25');|
I know that I can find the next recored in a array using next. What I do not understand is if I know the last number was say 5 how do I tell the script that that is the current number so I can select the next record



What the next record?

Try:

    $array = array('0','1','3','5','8','15','25');
    $val = "5";

    echo($array[array_search($val, $array)+1]);

Cheers,

tedd


Not quite:

$array = array('0','1','3','5','8','15','25');
$val = "25";

echo($array[array_search($val, $array)+1]);

Notice: Undefined offset: 7 ...

brian


Duh?

You program for that -- you want me to write the entire code?


~sigh~

Grasshopper, the point i was trying to make is that your example displays what *not* to do with array_search(). Though a wonderful teaching aid in itself, it falls somewhat short of being a reasonable solution for the OP.

brian

~sigh~

Sorry to disappoint you master. But I was using array_search() to search an array -- it seemed like a reasonable thing to do.

So why do you say it's an example of what *not* to do with array_search()?

Please be specific.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux