note 88938 added to function.next

From: Date: Sat, 14 Feb 2009 02:43:43 +0000
Subject: note 88938 added to function.next
Groups: php.notes 
Request: Send a blank email to php-notes+get-150644@lists.php.net to get a copy of this message
I've taken lukasz's solution below on finding the neighbors of keys and made it a bit more sensible (in my opinion): function getKeyBeforeKey($arr, $key) { $keys = array_keys($arr); $keyIndexes = array_flip($keys); if (isset($keys[$keyIndexes[$key]-1])) { return $keys[$keyIndexes[$key]-1]; } else { return false; } } function getKeyAfterKey($arr, $key) { $keys = array_keys($arr); $keyIndexes = array_flip($keys); if (isset($keys[$keyIndexes[$key]+1])) { return $keys[$keyIndexes[$key]+1]; } else { return false; } } ---- Server IP: 208.69.120.35 Probable Submitter: 68.74.29.67 ---- Manual Page -- http://www.php.net/manual/en/function.next.php Edit -- https://master.php.net/note/edit/88938 Del: integrated -- https://master.php.net/note/delete/88938/integrated Del: useless -- https://master.php.net/note/delete/88938/useless Del: bad code -- https://master.php.net/note/delete/88938/bad+code Del: spam -- https://master.php.net/note/delete/88938/spam Del: non-english -- https://master.php.net/note/delete/88938/non-english Del: in docs -- https://master.php.net/note/delete/88938/in+docs Del: other reasons-- https://master.php.net/note/delete/88938 Reject -- https://master.php.net/note/reject/88938 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150644) next »