RE: [PHP-WIN] Array question
| From: | Warren Vail | Date: | Mon, 25 Aug 2003 07:33:14 +0000 |
| Subject: | RE: [PHP-WIN] Array question | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-21237@lists.php.net to get a copy of this message | ||
in my experience, using numeric indices to your array, you can deposit and
reference occurances as follows; however your reference is not a valid
array definition;
[0] => 1 [1] => 2 [2] => 3 ... [99] => 100 (I don't believe these are valid
as a definition)
numeric indices would be defined as follows;
array(0 => 1, 1 => 2, 2 => 3 .... 99 => 100);
$x = $dataarray[50];
$dataarray[50 - 2] = $x;
$dataarray[50 + 1] = $x;
if($dataarray[71] == 74) do this....
On the other hand, if the indices is alpha-numeric string representations of
numbers,
array("0" => 1, "1" => 2, "2" => 3 ... "99" =>
100)
you will need to use some other tricks to access them.
hope this is what you are looking for, you used several terms like "select"
and "know the value" of that are somewhat ambiguous ;-)
Warren Vail
warren@vailtech.net
-----Original Message-----
From: Disko_kex [mailto:disko_kex@swedish-mushroom.com]
Sent: Sunday, August 24, 2003 11:59 PM
To: php-windows@lists.php.net
Subject: [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