// This is how I would do it. The first question is easily solved by putting a mathematical // expression inside the array brackets. $selectIndex = 50; // The index you're interested in $selectedValue = yourArray[$select]; $selectedValueMinus2 = yourArray[$select-2]; $selectedValuePlus1 = yourArray[$select+1]; // The second problem would force me to loop through the array, though. $selectValue = 71; // The value you want to look for $sizeOfArray = count($yourArray); // Number of elements in your array // Search through the array for the value you want, break when found for($i=0;$i<$sizeOfArray;$i++){ if($yourArray[$i]==$selectValue) break; } // $i contains the position of the value in the array // Lycka till! // Joachim -----Ursprungligt meddelande----- Fran: Disko_kex [mailto:disko_kex@swedish-mushroom.com] Skickat: den 25 augusti 2003 08:59 Till: php-windows@lists.php.net Amne: [PHP-WIN] Array question If I have an array like this > [0] => 1 [1] => 2 [2] => 3 ... [99] => 100 If I want to select [50] => 51 and store the value that's 2 positions before and 1 position after, how can I do? If I want to know what position value 71 have? I have search the PHP-manual and found some functions as prev, next, pos etc. But with these commands I have to loop thru the array every time to reach the the values and positions. It has to be an easier way to do it. // jocke -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php