Re: Finding next recored in a array
| From: | Richard Kurth | Date: | Mon, 17 Sep 2007 01:04:45 +0000 |
| Subject: | Re: Finding next recored in a array | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262154@lists.php.net to get a copy of this message | ||
Richard Kurth wrote:
Rick Pasotto wrote:But now it works perfectOn Sun, Sep 16, 2007 at 07:09:02PM -0400, brian wrote:I tried this and it gives me nothing back. It should give me a 8 $Campaign_array= array('0','1','3','5','8','15','25'); $val="5"; $k = array_search($val,$Campaign_array); if ($k + 1 > count($Campaign_array)) { echo $Campaign_array[$k + 1]; } I figured out way it was not working $k + 1 > count needed to be $k + 1 < countRichard Kurth wrote:Nope. Just use array_search(). $k = array_search('5',$Campaign_array); if ($k + 1 > count($Campaign_array)) { echo $Campaign_array[$k + 1]; }$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 ||I think you'll need your own function for this.